nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.75k stars 483 forks source link

Enable type checking from vue-i18n #2591

Closed dreitzner closed 1 week ago

dreitzner commented 11 months ago

Describe the feature

vue-i18n supports type safe resource Schemas. (docs)

It would be nice to have a way to do the same in nuxt-i18n as well.

From what I can gleen from the source code it might only be needed to add a possible type type to defineNuxtPlugin that is passed to createI18n.

Additional information

Final checks

danwithabox commented 8 months ago

For people who want type-safety out-of-the-box without waiting for this, I have successfully used global resource schema type definitions as a workaround.

adamdehaven commented 5 months ago

I'm willing to contribute, but might need an assist: https://github.com/nuxt-modules/i18n/issues/1753#issuecomment-2146330404

thomaslecoeur commented 4 months ago

For people who want type-safety out-of-the-box without waiting for this, I have successfully used global resource schema type definitions as a workaround.

Any details on the implementation? Can we reproduce on a vanilla nuxt project?

BobbieGoede commented 1 month ago

The latest v9 release candidate (https://github.com/nuxt-modules/i18n/releases/tag/v9.0.0-rc.2) includes experimental vue-i18n options and messages generation, this provides autocompletion for configuring options and translation functions, please try it out and let me know if this works as expected 🙏

More on the option that enables this functionality: https://i18n.nuxtjs.org/docs/v9/options/misc#experimentaltypedoptionsandmessages, the PR implementing this has a demo video of it in action https://github.com/nuxt-modules/i18n/pull/3151

BobbieGoede commented 1 week ago

Closing this as we have experimental support for this in the stable release of v9, please try it out and let me know your thoughts!