simple-content-site 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/modules/config.ts +13 -8
- package/package.json +1 -1
package/modules/config.ts
CHANGED
|
@@ -50,10 +50,11 @@ export default defineNuxtModule({
|
|
|
50
50
|
})
|
|
51
51
|
|
|
52
52
|
/*
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
** I18N
|
|
54
|
+
*/
|
|
55
55
|
if (nuxt.options.i18n && nuxt.options.i18n.locales) {
|
|
56
56
|
const { resolve } = createResolver(import.meta.url)
|
|
57
|
+
const { resolve: resolveRoot } = createResolver(dir)
|
|
57
58
|
|
|
58
59
|
// Filter locales to only include existing ones
|
|
59
60
|
const filteredLocales = nuxt.options.i18n.locales.filter((locale) => {
|
|
@@ -79,10 +80,9 @@ export default defineNuxtModule({
|
|
|
79
80
|
})
|
|
80
81
|
|
|
81
82
|
// Override strategy to prefix
|
|
82
|
-
nuxt.options.i18n = {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
83
|
+
nuxt.options.i18n = defu(nuxt.options.i18n, {
|
|
84
|
+
strategy: 'prefix_except_default',
|
|
85
|
+
}) as typeof nuxt.options.i18n
|
|
86
86
|
|
|
87
87
|
// Expose filtered locales
|
|
88
88
|
nuxt.options.runtimeConfig.public.Site = {
|
|
@@ -93,16 +93,21 @@ export default defineNuxtModule({
|
|
|
93
93
|
const langDir = resolve('../i18n/locales')
|
|
94
94
|
|
|
95
95
|
const locales = filteredLocales?.map((locale) => {
|
|
96
|
+
// Possibly load custom translations.
|
|
97
|
+
const localeCode = typeof locale === 'string' ? locale : locale.code
|
|
98
|
+
const customLocalePath = resolveRoot('i18n/locales', `${localeCode}.json`)
|
|
99
|
+
const hasCustomLocale = existsSync(customLocalePath)
|
|
100
|
+
const files = hasCustomLocale ? [customLocalePath, `${localeCode}.json`] : [`${localeCode}.json`]
|
|
96
101
|
return typeof locale === 'string'
|
|
97
102
|
? {
|
|
98
103
|
code: locale,
|
|
99
104
|
name: locale,
|
|
100
|
-
|
|
105
|
+
files,
|
|
101
106
|
}
|
|
102
107
|
: {
|
|
103
108
|
code: locale.code,
|
|
104
109
|
name: locale.name || locale.code,
|
|
105
|
-
|
|
110
|
+
files,
|
|
106
111
|
}
|
|
107
112
|
})
|
|
108
113
|
|