mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 15:25:46 +00:00
209dd61442
Move domain-agnostic, feature-free helpers out of the flat utils/ and store/ roots into src/lib/ (plan M4, §3 lib/ layer): - lib/format/: formatBytes, formatClockTime, formatDuration, formatHumanDuration, relativeTime (pure format/date/byte/clock helpers) - lib/i18n.ts: i18next bootstrap (global app infra) - lib/util/: sanitizeHtml, platform, dedupeById, safeStorage (pure helpers + the zustand storage adapter) playbackScheduleFormat stays in utils/format (runtime usePlayerStore dep = audio-core coupling, not generic). formatClockTime keeps a type-only @/store/authStoreTypes import (erased, no runtime inversion — accepted per the deviceSync precedent). Pure move via deep @/lib/* specifiers (no barrel → no mock-collapse surface). tsc 0, lint 0/0, full suite 319 files / 2353 tests green. Tooling note: lib_move.py regex extended to also rewrite side-effect imports (import './i18n') and vi.importActual paths — both were silent gaps.
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import i18n from 'i18next';
|
|
import { initReactI18next } from 'react-i18next';
|
|
import { deTranslation } from '@/locales/de';
|
|
import { enTranslation } from '@/locales/en';
|
|
import { frTranslation } from '@/locales/fr';
|
|
import { zhTranslation } from '@/locales/zh';
|
|
import { nbTranslation } from '@/locales/nb';
|
|
import { ruTranslation } from '@/locales/ru';
|
|
import { nlTranslation } from '@/locales/nl';
|
|
import { esTranslation } from '@/locales/es';
|
|
import { roTranslation } from '@/locales/ro';
|
|
import { jaTranslation } from '@/locales/ja';
|
|
import { huTranslation } from '@/locales/hu';
|
|
import { plTranslation } from '@/locales/pl';
|
|
|
|
const savedLanguage = localStorage.getItem('psysonic_language') || 'en';
|
|
|
|
i18n
|
|
.use(initReactI18next)
|
|
.init({
|
|
resources: {
|
|
en: { translation: enTranslation },
|
|
de: { translation: deTranslation },
|
|
es: { translation: esTranslation },
|
|
fr: { translation: frTranslation },
|
|
nl: { translation: nlTranslation },
|
|
zh: { translation: zhTranslation },
|
|
nb: { translation: nbTranslation },
|
|
ru: { translation: ruTranslation },
|
|
ro: { translation: roTranslation },
|
|
ja: { translation: jaTranslation },
|
|
hu: { translation: huTranslation },
|
|
pl: { translation: plTranslation },
|
|
},
|
|
lng: savedLanguage,
|
|
fallbackLng: 'en',
|
|
interpolation: {
|
|
escapeValue: false,
|
|
},
|
|
});
|
|
|
|
i18n.on('languageChanged', lng => {
|
|
localStorage.setItem('psysonic_language', lng);
|
|
});
|
|
|
|
export default i18n;
|