Closed joaquinCaceres closed 1 week ago
Hi @joaquinCaceres I've had the same issue. Try using defineI18nLocale
function in your translation file.
So instead of this:
export default {
portfolioMain,
blogMain,
"section-name": "about me"
}
do this:
export default defineI18nLocale(() => {
portfolioMain,
blogMain,
"section-name": "about me"
});
You can read more about that here -> https://i18n.nuxtjs.org/docs/guide/lazy-load-translations
Would you be able to provide a reproduction? 🙏
Closing due to inactivity. Please open a new issue with a reference to this one if you can follow up with more information.
Thanks!
Environment
Build Modules: -
Reproduction
.
Describe the bug
I'm trying to config a locale whose file is a javascript file that return a object. if the dictionary is simple like {‘title’: ‘about’, ‘data’: ‘the data’} everything works correctly and I can access those values via $t(title) without problems. However, if the dictionary includes other elements imported from other js files, I am not able to access them.
The configuration of my environment is as follows:
NUXT.CONFIG.TS:
export default defineNuxtConfig({ devtools: { enabled: true }, modules: ["@nuxtjs/i18n"], i18n: { lazy: true, langDir: "./locales", strategy: 'prefix_and_default', locales: [ { code: "en", name: "English(US)", file: "en/index.js", }, { code: "es", name: "Español", file: "es/index.js", }, ], defaultLocale: "es", } })
INDEX.JS
import portfolioMain from './pages/portfolioMain' import blogMain from './pages/blogMain'
export default { portfolioMain, blogMain, "section-name": "about me"
}
PORTFOLIOMAIN.JS
export default { title: 'the house' }
In this configuration, I can access to section-name without problems. Could I help me, please? My intention is to have the files as tidy as possible within the directory
Additional context
No response
Logs