-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
Allow loading of translations from packages #2999
Comments
Thank you for your feedback and pull-requesting! ❤️ I like your idea as it makes it easy to load locals.
I have considered lightly for alternatives. I think that loading a locale from a package can be done by specifying it in |
Thanks for the quick feedback @kazupon! 👍 I agree, getting rid of the So if I got that right for v9 you'd imagine something like this? export default defineNuxtConfig({
i18n: {
lazy: true,
defaultLocale: 'en'
locales: [
{
code: 'en',
name: 'English',
files: ['my-module/locales/en.json', './i18n/locales/en.json']
}
],
}
}) I like the idea but would it be possible to add this feature as non breaking within v8 already? From the checkboxes inside the roadmap it looks like v9 could still take a moment but at least to me this feature would already be pretty useful right now. :) |
This PR fixes an issue with the registration order warning of the nuxt module. It also requires the user to specify a mapping for onyx locales to the locales from nuxt-i18n specific to their project. This fixes a bug where all projects would display all locales of onyx as supported languages even if they were not specified within the project. An issue and PR were already created for nuxt-i18n to support loading locales from npm packages. (nuxt-modules/i18n#2999) This way it would be possible to decouple onyx and nuxt-i18n while preserving easy support and customizability. This PR should make the onyx module useable until the feature is available inside nuxt-i18n.
Describe the feature
Hi,
first of all thanks for creating and maintaining this amazing nuxt module. ❤️
Context
I'm currently working on a nuxt module for a component library that ships with default translations. I integrated this module to automatically handle all the translations by registering the component libraries translations under a scope, so it's easy to extend and overwrite them.
All of this works great with just the one exception that all locales of the module will now show up inside the project using it.
For example: If the component library registers the languages en-US and de-DE but the project only defines en-US, de-DE will still be shown as a locale.
All of this could be simplified by just importing the translations for the component library inside the project manually.
Proposed feature
Allow using node modules inside the files property of a locale
The feature could look something like this:
By adding a property
external
to the LocalFile type it would be possible to ignore the langDir and load it from node_modules instead.Optionally a second property
scope
could be useful to scope the imported messages to avoid conflicts between the different files. Like in the example for the locale "en-US" where the messages for the component library would later be accessible under the key "onyx.*".Additional information
Final checks
The text was updated successfully, but these errors were encountered: