Reverted all changes back to version 3523287dff

This commit is contained in:
[dyad]
2026-01-18 16:04:31 +01:00
parent c53d445b86
commit 35b7518b77

View File

@@ -12,7 +12,7 @@ interface I18nContextType {
const I18nContext = createContext<I18nContextType | undefined>(undefined);
const translations: { [key: string]: any } = {
const translations: { [key: string]: { [key: string]: string } } = {
en,
de,
};
@@ -21,21 +21,13 @@ export function I18nProvider({ children }: { children: ReactNode }) {
const [language, setLanguage] = useState('en');
const t = (key: string, params?: { [key: string]: string | number }) => {
const translation = key.split('.').reduce((acc, currentKey) => {
if (acc && typeof acc === 'object' && currentKey in acc) {
return acc[currentKey];
}
return undefined;
}, translations[language]);
let result = (typeof translation === 'string' ? translation : key);
let translation = translations[language]?.[key] || key;
if (params) {
Object.keys(params).forEach(paramKey => {
result = result.replace(`{${paramKey}}`, String(params[paramKey]));
translation = translation.replace(`{${paramKey}}`, String(params[paramKey]));
});
}
return result;
return translation;
};
return (