style: fix formatting via prettier

This commit is contained in:
2026-08-28 14:29:54 +05:00
parent 10278981ba
commit ada96b3534
124 changed files with 8211 additions and 5662 deletions
+9 -11
View File
@@ -1,15 +1,15 @@
import { BASE_LOCALE, isLocale, type Dict, type Locale } from './dict';
import { ru } from './ru';
import { en } from './en';
import { BASE_LOCALE, isLocale, type Dict, type Locale } from "./dict";
import { ru } from "./ru";
import { en } from "./en";
const STORAGE_KEY = 'locale';
const STORAGE_KEY = "locale";
const DICTS: Record<Locale, Dict> = { ru, en };
let locale = $state<Locale>(BASE_LOCALE);
function storage(): Storage | null {
return typeof localStorage === 'undefined' ? null : localStorage;
return typeof localStorage === "undefined" ? null : localStorage;
}
export function getLocale(): Locale {
@@ -29,13 +29,11 @@ export function getMergedDict(): Dict {
get(_target, section: string) {
const a = (active as unknown as Record<string, unknown>)[section];
const b = (base as unknown as Record<string, unknown>)[section];
if (
a && b && typeof a === 'object' && typeof b === 'object'
) {
if (a && b && typeof a === "object" && typeof b === "object") {
return { ...(b as object), ...(a as object) };
}
return a ?? b;
}
},
}) as Dict;
}
@@ -47,14 +45,14 @@ export function setLocale(next: Locale): void {
/** Читает сохранённый выбор и синхронизирует атрибут lang. Вызывается на клиенте. */
export function initLocale(): void {
if (typeof window === 'undefined') return;
if (typeof window === "undefined") return;
const saved = storage()?.getItem(STORAGE_KEY);
if (isLocale(saved)) locale = saved;
syncLangAttr();
}
function syncLangAttr(): void {
if (typeof document !== 'undefined') {
if (typeof document !== "undefined") {
document.documentElement.lang = locale;
}
}