images optimizations

This commit is contained in:
Salam-vsem
2025-05-14 01:15:30 +03:00
parent 5d9b7c27ae
commit 2f26ad5464
14 changed files with 130 additions and 63 deletions

View File

@@ -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]
}
}