-
Notifications
You must be signed in to change notification settings - Fork 1
/
nuxt.config.ts
72 lines (67 loc) · 1.93 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
// https://nuxt.com/docs/api/configuration/nuxt-config
import fs from "node:fs";
import { redirects } from "./redirects";
let redirectMap: any = {};
for (const redirect of redirects) {
redirectMap[redirect[0]] = { redirect: redirect[1] };
}
const languages = fs.readdirSync('./lang').map((file) => file.split('.')[0]);
function capitalize(string: any) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function getName(lang) {
switch(lang) {
case 'ms':
return 'Bahasa Melayu';
case 'ms-arab':
return 'بهاس ملايو';
case 'zh':
return '中文(香港特別行政區)';
case 'qep':
return 'Anglish';
default:
return capitalize(new Intl.DisplayNames([lang], { type: 'language' }).of(lang));
}
}
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ['@nuxtjs/color-mode', '@nuxtjs/i18n', "@nuxt/image"],
nitro: {
preset: 'github-pages',
},
colorMode: {
preference: 'system',
fallback: 'light',
componentName: 'ColorScheme',
classSuffix: '',
storageKey: 'nuxt-color-mode'
},
routeRules: {
...redirectMap
},
i18n: {
vueI18n: 'old.i18n.config.ts',
locales: languages.map((lang) => ({
code: lang, name: getName(lang), file: `${lang}.json`
})),
compilation: {
strictMessage: false,
},
detectBrowserLanguage: {
// If enabled, a cookie is set once a user has been redirected to his
// preferred language to prevent subsequent redirections
// Set to false to redirect every time
useCookie: true,
// Cookie name
cookieKey: 'i18n_redirected',
// Set to always redirect to value stored in the cookie, not just once
alwaysRedirect: false,
// If no locale for the browsers locale is a match, use this one as a fallback
fallbackLocale: 'en',
},
lazy: true,
strategy: 'no_prefix',
langDir: 'lang',
defaultLocale: 'en'
},
})