I18N problem

Hi, i'm having a problem with i18n config in my project. So, here how it looks like:
export default defineI18nConfig(() => ({
lazy: true,
langDir: "lang",
strategy: 'prefix_except_default',
defaultLocale: 'ru',
fallbackLocale: 'ru',
silentFallbackWarn: true,
warnHtmlInMessage: 'off',
locales: [
{ code: 'ru', iso: 'ru-RU', name: "RU", file: 'ru-RU.json' },
{ code: 'en', iso: 'en-US', name: "EN", file: 'en-US.json' },
],
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'i18n_redirected',
redirectOn: 'root',
alwaysRedirect: true
}
}))
export default defineI18nConfig(() => ({
lazy: true,
langDir: "lang",
strategy: 'prefix_except_default',
defaultLocale: 'ru',
fallbackLocale: 'ru',
silentFallbackWarn: true,
warnHtmlInMessage: 'off',
locales: [
{ code: 'ru', iso: 'ru-RU', name: "RU", file: 'ru-RU.json' },
{ code: 'en', iso: 'en-US', name: "EN", file: 'en-US.json' },
],
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'i18n_redirected',
redirectOn: 'root',
alwaysRedirect: true
}
}))
And for some reason i keep getting these warnings:
WARN [intlify] Not found 'header.company' key in 'en' locale messages.


WARN [intlify] Fall back to translate 'header.company' key with 'ru' locale.


WARN [intlify] Not found 'header.company' key in 'ru' locale messages.
WARN [intlify] Not found 'header.company' key in 'en' locale messages.


WARN [intlify] Fall back to translate 'header.company' key with 'ru' locale.


WARN [intlify] Not found 'header.company' key in 'ru' locale messages.
But if i would pass same config not in i18n.config.ts, but in nuxt.config.js just by object, everything works perfectly fine. The only reason i have to use i18n.config.ts but not the main config is because i need to use html inside by locales, which i can only allow with warnHtmlInMessage key, which doesn't work if you pass it in nuxt.config.ts
6 Replies
BraindeadDogge
BraindeadDoggeOP7mo ago
I've also made a test project just for that, and it's also not working here. I really don't understand what am i doing wrong
Muhammad Mahmoud
The default folder is locales but you're using lang That's why it's failing. You should move your files into locales folder or change langDir to lang in i18n options
BraindeadDogge
BraindeadDoggeOP7mo ago
Check twice: i've changed it in options, but anyway it doesn't work with locales folder either
dwol
dwol7mo ago
Don’t you need ‘legacy: false’ in the config?
Muhammad Mahmoud
Make a reproduction
dwol
dwol7mo ago
Here is my config which is working just fine: i18n.config.ts
export default defineI18nConfig(() => ({
legacy: false,
fallbackLocale: 'en-CA'
}))
export default defineI18nConfig(() => ({
legacy: false,
fallbackLocale: 'en-CA'
}))
nuxt.config.ts
export default defineNuxtConfig({
i18n: {
locales: [
{
name: 'English',
code: 'en-CA',
iso: 'en-CA',
dir: 'ltr',
file: 'en-CA.ts'
},
{
name: 'Français',
code: 'fr-CA',
iso: 'fr-CA',
dir: 'ltr',
file: 'fr-CA.ts'
}
],
strategy: 'prefix',
lazy: true,
langDir: 'locales',
defaultLocale: 'en-CA',
detectBrowserLanguage: false,
vueI18n: './i18n.config.ts'
}
})
export default defineNuxtConfig({
i18n: {
locales: [
{
name: 'English',
code: 'en-CA',
iso: 'en-CA',
dir: 'ltr',
file: 'en-CA.ts'
},
{
name: 'Français',
code: 'fr-CA',
iso: 'fr-CA',
dir: 'ltr',
file: 'fr-CA.ts'
}
],
strategy: 'prefix',
lazy: true,
langDir: 'locales',
defaultLocale: 'en-CA',
detectBrowserLanguage: false,
vueI18n: './i18n.config.ts'
}
})
Want results from more Discord servers?
Add your server