i18n: add language aliasing
This commit is contained in:
1 parent
1804d9efee
commit
4b42e40817
5 files changed
+71
-26
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { loadTranslations, locales } from '$lib/translations.js'
|
||||
import { aliases, loadTranslations, locales } from '$lib/translations.js'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
export const load = async ({ url, request }) => {
|
||||
@@ -13,8 +13,8 @@ export const load = async ({ url, request }) => {
|
||||
}
|
||||
for (const lang of languages.reverse()) {
|
||||
const splitLang = lang.split(';')[0]
|
||||
if (availableLangs.includes(splitLang)) {
|
||||
preferredLanguage = splitLang
|
||||
if (availableLangs.includes(splitLang) || aliases.get(splitLang)) {
|
||||
preferredLanguage = aliases.get(splitLang) || splitLang
|
||||
}
|
||||
}
|
||||
await loadTranslations(preferredLanguage)
|
||||
|
||||
Reference in new issue
Block a user