Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate messages type #50

Draft
wants to merge 6 commits into
base: feat/locale-type-generation
Choose a base branch
from

Conversation

BobbieGoede
Copy link
Owner

@BobbieGoede BobbieGoede commented Jul 16, 2024

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This is still very much a work in progress!

For message type inference we need to merge the messages provided by all Vue I18n configs and locale files (probably limited to default language or a configured 'master' locale for perf) and use the merged messages to generate the messages type.

The generation of these types is still incomplete, we may not be able to (properly) support async locale configs due to its reliance on the Nuxt context ($fetch, useRuntimeConfig, etc.), this is the case for both defineI18nLocale and defineI18nConfig.

Maybe we should consider having a clear split between 'static' locale configs and 'runtime' configs instead of allowing both in defineI18nLocale? This would make it possible to generate types for such locales and bundle/fetch remote translations at build time if users prefer to do so.

Code_2024-07-17_14-54-20.mp4

📝 Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

@BobbieGoede BobbieGoede changed the base branch from main to feat/locale-type-generation July 16, 2024 11:43
@kazupon
Copy link

kazupon commented Jul 16, 2024

Maybe we should consider having a clear split between 'static' locale configs and 'runtime' configs instead of allowing both in defineLocaleConfig? This would make it possible to generate types for such locales and bundle/fetch remote translations at build time if users prefer to do so.

Yeah, it make sense!
By separating static and dynamic locales as defineStaticLocales and defineRuntimeLocales, We can clarify locales management!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants