images optimizations
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import { ui } from './ui';
|
||||
import { ui } from './ui'
|
||||
|
||||
import { i18n } from 'astro:config/client';
|
||||
import { i18n } from 'astro:config/client'
|
||||
|
||||
export function getLangFromUrl(url: URL) {
|
||||
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 i18n!.defaultLocale;
|
||||
return i18n!.defaultLocale
|
||||
}
|
||||
|
||||
export function useTranslations(lang?: string) {
|
||||
return function t(key: keyof (typeof ui)[keyof typeof ui]) {
|
||||
return ui[lang as keyof typeof ui]?.[key] || ui[i18n!.defaultLocale as keyof typeof ui][key];
|
||||
};
|
||||
return ui[lang as keyof typeof ui]?.[key] || ui[i18n!.defaultLocale as keyof typeof ui][key]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user