vue-i18n
vue-i18n copied to clipboard
[Feature Request] Namespaced translations
Clear and concise description of the problem
I would like to be able to organise my translations into multiple namespaces, to better organise my code.
Suggested solution
Add namespaced translations (mostly useful with lazy loading). The namespace would be part of the translation key, and would be separated by a colon (if there is no colon in the translation key, current semantics would apply). E.G. core:foo.bar takes foo.bar from the namespace core. This would then allow lazy loading from separate files.
Alternative
No response
Additional context
This is part of the proposed solution to #957, but I felt it deserved its own issue. vue-i18n seems to be the defacto standard for internationalisation in Vue, but the lack of namespaces is a blocker for me. Some of my translation files are large (I have a single file that's over 25K)
Validations
- [X] Read the Contributing Guidelines
- [X] Read the Documentation
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@kazupon would it be an idea to combine i18next with vue-i18n?
Using i18next as a core you get:
- namespace support
- support for flexible backends (how to load those namespaces if not bundled)
- language detection for browser, http-middlewares, ...
- the vue-i18n format could be supported with your syntax adding it as a i18n-format like done eg. for polyglot: https://github.com/i18next/i18next-polyglot (there are also options for ICU, ...)
Using vue-i18n you get all that super neat vue integration (like we do for react with react-i18next)
I created an extension for vue-i18n specifically for this feature: https://github.com/modernice/vue-i18n-modules Maybe this will suit the needs of anyone who stumbles across this issue
I think that this issue should be solved together with lazy loading. I’m working on nuxtjs/i18n for nuxt3. This has also given me a better understanding of the i18n routing. And recent technical topics, there are some topics, native ES modules and glob import for vite and another bundler, and router data fetching in the upcoming RFC for the vue router. I will try to work on these issue nuxtjs/i18n development is finished.