Reputation: 127
I have an application, the main problem is that i can't understand how to "create" custom locale. For example i have routes like this /hello
and /ja/hello
, where the first route is default english language and the second one is japanese. I trying to left my english locale without prefix, but add the prefix only for one route of this version like /eng/hello
.
My nuxt.config.js for i18n:
i18n: {
locales: [
{
code: 'en',
file: 'en.js',
domain: domains.en,
icon: 'english',
name: 'English',
iso: 'en',
},
{
code: 'ja',
file: 'ja.js',
domain: domains.ja,
icon: 'japan',
name: '日本語',
iso: 'ja',
},
],
// differentDomains: true,
lazy: true,
langDir: 'lang/',
defaultLocale: 'en',
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'clang',
onlyOnRoot: true, // recommended
alwaysRedirect: true,
},
seo: false,
strategy: 'prefix_except_default',
},
Upvotes: 1
Views: 1104
Reputation: 320
Try configuring under the modules prop like this, example from my project:
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
'nuxt-socket-io',
'@nuxtjs/axios',
'@nuxtjs/auth-next',
['nuxt-i18n', {
locales: [
{
name: 'Türkçe',
code: 'tr',
iso: 'tr-TR',
file: 'tr-TR.js'
},
{
name: 'English',
code: 'en',
iso: 'en-US',
file: 'en-US.js'
},
],
langDir: 'lang/',
defaultLocale: 'en',
}]
],
i18n: {},
Upvotes: 0