`import as en from "./languages/en.json";
import as es from "./languages/es.json";
import as fr from "./languages/fr.json";
import as it from "./languages/it.json";
import as pt from "./languages/pt.json";
import as ru from "./languages/ru.json";
import as sk from "./languages/sk.json";
import as uk from "./languages/uk.json";
import * as hu from "./languages/hu.json";
Created hu.json Modified localize.ts to include hu.json
hu.json
`import as en from "./languages/en.json"; import as es from "./languages/es.json"; import as fr from "./languages/fr.json"; import as it from "./languages/it.json"; import as pt from "./languages/pt.json"; import as ru from "./languages/ru.json"; import as sk from "./languages/sk.json"; import as uk from "./languages/uk.json"; import * as hu from "./languages/hu.json";
// eslint-disable-next-line @typescript-eslint/no-explicit-any const languages: any = { en: en, es: es, fr: fr, it: it, ru: ru, sk: sk, pt: pt, uk: uk, hu: hu };
export function localize(string: string, search = '', replace = ''): string { const lang = (localStorage.getItem('selectedLanguage') || 'en').replace(/['"]+/g, '').replace('-', '_');
let translated: string;
try { translated = string.split('.').reduce((o, i) => o[i], languages[lang]); } catch (e) { translated = string.split('.').reduce((o, i) => o[i], languages['en']); }
if (translated === undefined) translated = string.split('.').reduce((o, i) => o[i], languages['en']);
if (search !== '' && replace !== '') { translated = translated.replace(search, replace); } return translated; }`