forked from nuxt-modules/i18n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.config.ts
99 lines (95 loc) · 2.31 KB
/
nuxt.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import Module1 from './module1'
import type { NuxtApp } from 'nuxt/dist/app/index'
// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
export default defineNuxtConfig({
modules: [Module1, '@nuxtjs/i18n'],
vite: {
build: {
minify: false
}
},
// app: {
// pageTransition: {
// name: 'foo',
// onBeforeEnter: async (...args: unknown[]) => {
// console.log('global onBeforeEnter', ...args)
// }
// }
// },
i18n: {
langDir: 'locales',
lazy: true,
baseUrl: 'http://localhost:3000',
locales: [
{
code: 'en',
iso: 'en-US',
file: 'en.json',
// domain: 'localhost',
name: 'English'
},
{
code: 'ja',
iso: 'ja-JP',
file: 'ja.json',
domain: 'mydomain.com',
name: 'Japanses'
},
{
code: 'fr',
iso: 'fr-FR',
file: 'fr.json',
domain: 'mydomain.fr',
name: 'Français'
}
],
// trailingSlash: true,
debug: true,
defaultLocale: 'en',
// strategy: 'no_prefix',
// strategy: 'prefix',
strategy: 'prefix_and_default',
// rootRedirect: '/ja/about-ja',
dynamicRouteParams: true,
// customRoutes: 'config',
pages: {
about: {
ja: '/about-ja'
}
},
// differentDomains: true,
skipSettingLocaleOnNavigate: true,
detectBrowserLanguage: false,
/*
detectBrowserLanguage: {
useCookie: true,
// alwaysRedirect: true,
cookieKey: 'i18n_redirected',
// cookieKey: 'my_custom_cookie_name',
redirectOn: 'root'
},
//*/
onBeforeLanguageSwitch: (oldLocale: string, newLocale: string, initial: boolean, nuxt: NuxtApp) => {
console.log('onBeforeLanguageSwitch', oldLocale, newLocale, initial)
},
onLanguageSwitched: (oldLocale: string, newLocale: string) => {
console.log('onLanguageSwitched', oldLocale, newLocale)
},
// vueI18n: './vue-i18n.options.ts'
vueI18n: {
legacy: false,
locale: 'en',
fallbackLocale: 'en'
// messages: {
// ja: {
// hello: 'こんにちは!'
// }
// }
// fallbackLocale: {
// en: ['ja', 'fr', 'en-US'],
// ja: ['en', 'fr', 'ja-JP'],
// fr: ['en', 'ja', 'fr-FR']
// }
}
}
})