style: format entire codebase with prettier

This commit is contained in:
Rasmus Q
2026-03-15 21:02:57 +00:00
parent 47e02d81c3
commit f739288866
93 changed files with 5334 additions and 4976 deletions
+38 -38
View File
@@ -4,60 +4,60 @@ import type { Translation } from '$lib/i18n/translations/en';
const LANGUAGE_KEY = 'preferred-language';
function getStoredLanguage(): LanguageCode {
if (typeof window === 'undefined') return 'en';
if (typeof window === 'undefined') return 'en';
const stored = localStorage.getItem(LANGUAGE_KEY);
if (stored && (stored === 'en' || stored === 'da')) {
return stored as LanguageCode;
}
const stored = localStorage.getItem(LANGUAGE_KEY);
if (stored && (stored === 'en' || stored === 'da')) {
return stored as LanguageCode;
}
// Try to detect from browser
const browserLang = navigator.language.toLowerCase();
if (browserLang.startsWith('da')) {
return 'da';
}
// Try to detect from browser
const browserLang = navigator.language.toLowerCase();
if (browserLang.startsWith('da')) {
return 'da';
}
return 'en';
return 'en';
}
class LanguageStore {
private _current = $state<LanguageCode>(getStoredLanguage());
private _current = $state<LanguageCode>(getStoredLanguage());
get current(): LanguageCode {
return this._current;
}
get current(): LanguageCode {
return this._current;
}
set current(value: LanguageCode) {
this._current = value;
if (typeof window !== 'undefined') {
localStorage.setItem(LANGUAGE_KEY, value);
}
}
set current(value: LanguageCode) {
this._current = value;
if (typeof window !== 'undefined') {
localStorage.setItem(LANGUAGE_KEY, value);
}
}
get t(): Translation {
return translations[this._current];
}
get t(): Translation {
return translations[this._current];
}
setLanguage(lang: LanguageCode) {
this.current = lang;
}
setLanguage(lang: LanguageCode) {
this.current = lang;
}
}
export const languageStore = new LanguageStore();
// Helper function to get nested translation value
export function t(path: string): string {
const keys = path.split('.');
let value: any = languageStore.t;
const keys = path.split('.');
let value: any = languageStore.t;
for (const key of keys) {
if (value && typeof value === 'object' && key in value) {
value = value[key];
} else {
console.warn(`Translation key not found: ${path}`);
return path;
}
}
for (const key of keys) {
if (value && typeof value === 'object' && key in value) {
value = value[key];
} else {
console.warn(`Translation key not found: ${path}`);
return path;
}
}
return typeof value === 'string' ? value : path;
return typeof value === 'string' ? value : path;
}