No comma needed lol
This commit is contained in:
parent
ab3049dd84
commit
5a48e2d71e
1 changed files with 3 additions and 4 deletions
|
|
@ -4,14 +4,13 @@ type LanguageKeys = keyof typeof ui;
|
||||||
type TranslationKeys = keyof (typeof ui)[typeof defaultLang];
|
type TranslationKeys = keyof (typeof ui)[typeof defaultLang];
|
||||||
type StaticPath = { params: { lang: string } };
|
type StaticPath = { params: { lang: string } };
|
||||||
|
|
||||||
const STATIC_PATHS: StaticPath[] = [];
|
const STATIC_PATHS: StaticPath[] = [];
|
||||||
for (const lang in ui) {
|
for (const lang in ui) {
|
||||||
STATIC_PATHS.push({ params: { lang } });
|
STATIC_PATHS.push({ params: { lang } });
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLangFromUrl(url: URL) {
|
function getLangFromUrl(url: URL) {
|
||||||
// comma lol
|
const [lang] = url.pathname.split("/");
|
||||||
const [, lang] = url.pathname.split("/");
|
|
||||||
if (lang in ui) return lang as keyof typeof ui;
|
if (lang in ui) return lang as keyof typeof ui;
|
||||||
return defaultLang;
|
return defaultLang;
|
||||||
}
|
}
|
||||||
|
|
@ -31,4 +30,4 @@ function useTranslations(lang: LanguageKeys) {
|
||||||
|
|
||||||
export const i18n = { getLangFromUrl, useTranslations, inferLangUseTranslations };
|
export const i18n = { getLangFromUrl, useTranslations, inferLangUseTranslations };
|
||||||
|
|
||||||
export { STATIC_PATHS };
|
export { STATIC_PATHS };
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue