-
-
Notifications
You must be signed in to change notification settings - Fork 517
Description
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:
export default defineNuxtConfig({
modules: [
'@sit-onyx/nuxt',
'@nuxtjs/i18n',
],
i18n: {
defaultLocale: 'de-DE',
locales: [
{ code: 'de-DE', iso: 'de-DE', name: 'Deutsch', files: [{ path: '@sit-onyx/nuxt/locales/de-DE.json', external: true }, 'de-DE.json'] },
{ code: 'en-US', iso: 'en-US', name: 'English', files: [{ path: '@sit-onyx/nuxt/locales/en-US.json', external: true, scope: 'onyx' }, 'en_US.json'] },
],
langDir: 'i18n',
lazy: true,
},
});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
- Would you be willing to help implement this feature?
- Could this feature be implemented as a module?
Final checks
- Read the contribution guide (The contribution guideline of nuxt-modules/i18n is compliant with Nuxt too).
- Check existing discussions and issues.