diff --git a/src/localize/languages/et_old.json b/src/localize/languages/et_old.json deleted file mode 100755 index 622c58b2..00000000 --- a/src/localize/languages/et_old.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "scheduler": "Ajastaja", - "actions": { - "add": "lisa", - "cancel": "loobu", - "next": "edasi", - "save": "salvesta", - "delete": "kustuta" - }, - "instructions": { - "no_group_selected": "Vali grupp", - "no_entity_selected": "Vali olem", - "no_groups_defined": "Gruppe pole määratud", - "no_entities_for_group": "Antud grupis puuduvad olemid", - "no_actions_for_entity": "Selles olemis puuduvad tegevused", - "no_entries_defined": "Pole midagi kuvada" - }, - "fields": { - "group": "Grupp", - "entity": "Olem", - "action": "Tegevus", - "days": "Päevad", - "time": "Aeg", - "options": "Suvandid", - "day_type_daily": "iga päev", - "day_type_weekdays": "tööpäevadel", - "day_type_weekend": "nädalavahetus", - "day_type_custom": "valikuline" - }, - "days_short": { - "mon": "E", - "tue": "T", - "wed": "K", - "thu": "N", - "fri": "R", - "sat": "L", - "sun": "P" - }, - "days_long": { - "mon": "Esmaspäev", - "tue": "Teisipäev", - "wed": "Kolmapäev", - "thu": "Neljapäev", - "fri": "Reede", - "sat": "Laupäev", - "sun": "Pühapäev" - }, - "words": { - "and": "ja", - "before": "enne", - "after": "pärast" - }, - "services": { - "turn_on": "lülita sisse", - "turn_on_brightness": "turn on {at brightness}", - "turn_off": "lülita välja", - "close_cover": "sulge", - "open_cover": "ava", - "set_temperature": "määra temperatuur {to temperature}", - "set_temperature_hvac_mode_heat": "heat {to temperature}", - "set_temperature_hvac_mode_cool": "cool {to temperature}", - "set_cover_position": "seadista asendisse {to position}", - "set_hvac_mode": "vali töörežiim {to hvac_mode}", - "set_hvac_mode_hvac_mode_off": "turn off", - "set_preset_mode": "eelseadistatud {to preset_mode}", - "set_value": "määra väärtus {value}", - "select_option": "valikud {option}", - "select_source": "vali allikas {source}", - "start": "alusta", - "run_script": "alusta" - }, - "service_parameters": { - "brightness": "heledus", - "temperature": "temperatuur", - "position": "asend", - "hvac_mode": "töörežiim", - "preset_mode": "eelseadistus" - }, - "domains": { - "camera": "kaamerad", - "climate": "kliimaseade", - "cover": "(akna)katted", - "fan": "ventilaatorid", - "group": "grupid", - "input_boolean": "binaarsisestus", - "input_number": "arvsisestus", - "input_select": "sisendivalik", - "light": "valgustid", - "media_player": "media players", - "scene": "stseenid", - "switch": "lülitid", - "vacuum": "tolmuimejad" - }, - "days": { - "tomorrow": "homme", - "daily": "iga päev", - "daily_except_days": "iga päev välja arvatud {days}", - "working_days": "tööpäevadel", - "weekend": "nädalavahetusel", - "interval": "{startDay} kuni {endDay}" - }, - "time": { - "absolute": "kell {time}", - "relative": "{time} pärast", - "interval": "alates {startTime} kuni {endTime}", - "seconds": "{seconds} sekundi", - "hour": "1 tunni", - "hours": "{hours} tunni", - "minute": "1 minuti", - "minutes": "{minutes} minuti", - "now": "kohe", - "midnight": "keskööl", - "noon": "keskpäeval", - "at_sun_event": "{sunEvent}", - "sun_event_sunrise": "päikesetõusu", - "sun_event_sunset": "loojangut" - }, - "misc": { - "one_additional_task": "veel 1 ajastus", - "x_additional_tasks": "{count} ajastust" - } -} diff --git a/src/localize/languages/fr_old.json b/src/localize/languages/fr_old.json deleted file mode 100644 index b002349e..00000000 --- a/src/localize/languages/fr_old.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "scheduler": "Planificateur", - "actions": { - "add": "ajouter un item", - "cancel": "annuler", - "next": "suivant", - "save": "sauvegarder", - "delete": "effacer" - }, - "instructions": { - "no_group_selected": "Sélectionner un groupe en premier", - "no_entity_selected": "Sélectionner une entité en premier", - "no_groups_defined": "Il n'y a pas de groupe défini", - "no_entities_for_group": "Il n'y a pas d'entité dans ce groupe", - "no_actions_for_entity": "Il n'y a pas d'action pour cette entité", - "no_entries_defined": "Il n'y a pas d'item à afficher" - }, - "fields": { - "group": "Groupe", - "entity": "Entité", - "action": "Action", - "days": "Jours", - "time": "Temps", - "options": "Options", - "day_type_daily": "chaque jour", - "day_type_weekdays": "en semaine", - "day_type_weekend": "weekend", - "day_type_custom": "sur mesure" - }, - "days_short": { - "mon": "lun", - "tue": "mar", - "wed": "mer", - "thu": "jeu", - "fri": "ven", - "sat": "sam", - "sun": "dim" - }, - "days_long": { - "mon": "lundi", - "tue": "mardi", - "wed": "mercredi", - "thu": "jeudi", - "fri": "vendredi", - "sat": "samedi", - "sun": "dimanche" - }, - "words": { - "and": "et", - "before": "avant", - "after": "après" - }, - "services": { - "turn_on": "allumer", - "turn_on_brightness": "allumer {à brightness}", - "turn_off": "éteindre", - "close_cover": "fermer", - "open_cover": "ouvrir", - "set_temperature": "régler la température {à temperature}", - "set_temperature_hvac_mode_heat": "chauffage {à temperature}", - "set_temperature_hvac_mode_cool": "climatisation {à temperature}", - "set_cover_position": "position définie {à position}", - "set_hvac_mode": "choisir le mode {to hvac_mode}", - "set_hvac_mode_hvac_mode_off": "éteindre", - "set_preset_mode": "choisir le programme {to preset_mode}", - "set_value": "ajuster {to value}", - "select_option": "choisir l'option {option}", - "select_source": "choisir la source {source}", - "start": "démarrer", - "run_script": "lancer le script" - }, - "service_parameters": { - "brightness": "luminosité", - "temperature": "température", - "position": "position", - "hvac_mode": "mode", - "preset_mode": "programme" - }, - "domains": { - "camera": "caméras", - "climate": "climat", - "cover": "contrôleur", - "fan": "ventilateur", - "group": "groupe", - "input_boolean": "sélection logique", - "input_number": "sélection numérique", - "input_select": "sélection d'entrée", - "light": "lumière", - "media_player": "lecteurs multimédias", - "scene": "scènes", - "switch": "interrupteurs", - "vacuum": "aspirateur" - }, - "days": { - "tomorrow": "demain", - "daily": "quotidien", - "daily_except_days": "chaque jour sauf {days}", - "working_days": "jours de travail", - "weekend": "fin de semaine", - "interval": "{startDay} à {endDay}" - }, - "time": { - "absolute": "à {time}", - "relative": "dans {time}", - "interval": "de {startTime} à {endTime}", - "seconds": "{seconds} secondes", - "hour": "1 heure", - "hours": "{hours} heures", - "minute": "1 minute", - "minutes": "{minutes} minutes", - "now": "maintenant", - "midnight": "minuit", - "noon": "midi", - "at_sun_event": "à {sunEvent}", - "sun_event_sunrise": "lever du soleil", - "sun_event_sunset": "coucher du soleil" - }, - "misc": { - "one_additional_task": "1 tâche de plus", - "x_additional_tasks": "{count} autres tâches" - } -} diff --git a/src/localize/languages/it.json b/src/localize/languages/it.json index bc91aa5f..0524fd88 100755 --- a/src/localize/languages/it.json +++ b/src/localize/languages/it.json @@ -82,7 +82,7 @@ "tomorrow": "tomorrow", "repeated_days": "ogni {days}", "repeated_days_except": "ogni giorno tranne {excludedDays}", - "days_range": "dal {startDay} al {endDay}" + "days_range": "{if startDay is domenica} dalla domenica {else} dal {startDay} {if endDay is domenica} alla domenica {else} al {endDay}" }, "time": { "absolute": "alle {time}", @@ -125,4 +125,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/localize/languages/it_old.json b/src/localize/languages/it_old.json deleted file mode 100644 index 830a4aed..00000000 --- a/src/localize/languages/it_old.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "scheduler": "Schedulatore", - "actions": { - "add": "aggiungi oggetto", - "cancel": "annulla", - "next": "avanti", - "save": "salva", - "delete": "elimina" - }, - "instructions": { - "no_group_selected": "Seleziona prima un gruppo", - "no_entity_selected": "Seleziona prima un'entità", - "no_groups_defined": "Non ci sono gruppi definiti", - "no_entities_for_group": "Non ci sono entità in questo gruppo", - "no_actions_for_entity": "Non ci sono azioni per questa entità", - "no_entries_defined": "Non ci sono oggetti da visualizzare" - }, - "fields": { - "group": "Gruppo", - "entity": "Entità", - "action": "Azione", - "days": "Giorni", - "time": "Ora", - "options": "Opzioni", - "day_type_daily": "giornaliero", - "day_type_workday": "giorni lavorativi", - "day_type_weekend": "weekend", - "day_type_custom": "personalizzato" - }, - "days_short": { - "mon": "lun", - "tue": "mar", - "wed": "mer", - "thu": "gio", - "fri": "ven", - "sat": "sab", - "sun": "dom" - }, - "days_long": { - "mon": "lunedì", - "tue": "martedì", - "wed": "mercoledì", - "thu": "giovedì", - "fri": "venerdì", - "sat": "sabato", - "sun": "domenica" - }, - "words": { - "and": "e", - "before": "prima", - "after": "dopo" - }, - "services": { - "turn_on": "accendi", - "turn_on_brightness": "accendi {at brightness}", - "turn_off": "spegni", - "close_cover": "chiudi", - "open_cover": "apri", - "set_temperature": "imposta temperatura {to temperature}", - "set_temperature_hvac_mode_heat": "riscaldamento a {to temperature}", - "set_temperature_hvac_mode_cool": "raffreddamento a {to temperature}", - "set_cover_position": "imposta posizione {to position}", - "set_hvac_mode": "imposta modalità {to hvac_mode}", - "set_hvac_mode_hvac_mode_off": "spegni", - "set_preset_mode": "imposta programmazione {to preset_mode}", - "set_value": "imposta valore {value}", - "select_option": "seleziona opzione {option}", - "select_source": "seleziona sorgente {source}", - "start": "avvia", - "run_script": "esegui" - }, - "service_parameters": { - "brightness": "luminosità", - "temperature": "temperatura", - "position": "posizione", - "hvac_mode": "modalità", - "preset_mode": "programmazione" - }, - "domains": { - "camera": "telecamere", - "climate": "clima", - "cover": "cover", - "fan": "ventole", - "group": "gruppi", - "input_boolean": "input_boolean", - "input_number": "input_number", - "input_select": "input_select", - "light": "luci", - "media_player": "media player", - "scene": "scene", - "switch": "interruttori", - "vacuum": "aspirapolvere" - }, - "days": { - "tomorrow": "domani", - "daily": "giornaliero", - "daily_except_days": "tutti i giorni eccetto {days}", - "working_days": "giorni lavorativi", - "weekend": "weekend", - "interval": "{startDay} a {endDay}" - }, - "time": { - "absolute": "alle {time}", - "relative": "entro {time}", - "interval": "dalle {startTime} alle {endTime}", - "seconds": "{seconds} secondi", - "hour": "1 ora", - "hours": "{hours} ore", - "minute": "1 minuto", - "minutes": "{minutes} minuti", - "now": "ora", - "midnight": "mezzanotte", - "noon": "mezzogiorno", - "at_sun_event": "al {sunEvent}", - "sun_event_sunrise": "l' alba", - "sun_event_sunset": "tramonto" - }, - "misc": { - "one_additional_task": "un altro task", - "x_additional_tasks": "{count} altri task" - } -} diff --git a/src/localize/languages/pl_old.json b/src/localize/languages/pl_old.json deleted file mode 100644 index 147df843..00000000 --- a/src/localize/languages/pl_old.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "scheduler": "Harmonogram", - "actions": { - "add": "dodaj", - "cancel": "anuluj", - "next": "dalej", - "save": "zapisz", - "delete": "usuń" - }, - "instructions": { - "no_group_selected": "Najpierw wybierz grupę", - "no_entity_selected": "Najpierw wybierz encję", - "no_groups_defined": "Nie ma zdefiniowanych grup", - "no_entities_for_group": "Nie ma encji w tej grupie", - "no_actions_for_entity": "Nie ma akcji dla tej encji", - "no_entries_defined": "Nie ma elementów do pokazania" - }, - "fields": { - "group": "Grupa", - "entity": "Encja", - "action": "Akcja", - "days": "Dni", - "time": "Czas", - "options": "Opcje", - "day_type_daily": "codziennie", - "day_type_workday": "dni robocze", - "day_type_weekend": "weekend", - "day_type_custom": "niestandardowy" - }, - "days_short": { - "mon": "pon.", - "tue": "wt.", - "wed": "śr.", - "thu": "czw.", - "fri": "pt.", - "sat": "sob.", - "sun": "niedz." - }, - "days_long": { - "mon": "poniedziałek", - "tue": "wtorek", - "wed": "środa", - "thu": "czwartek", - "fri": "piątek", - "sat": "sobota", - "sun": "niedziela" - }, - "words": { - "and": "oraz", - "before": "przed", - "after": "po" - }, - "services": { - "turn_on": "włącz", - "turn_on_brightness": "włącz {at brightness}", - "turn_off": "wyłącz", - "close_cover": "zamknij", - "open_cover": "otwórz", - "set_temperature": "ustaw temperaturę {to temperature}", - "set_temperature_hvac_mode_heat": "heat {to temperature}", - "set_temperature_hvac_mode_cool": "cool {to temperature}", - "set_cover_position": "ustaw pozycję {to position}", - "set_hvac_mode": "ustaw tryb {to hvac_mode}", - "set_hvac_mode_hvac_mode_off": "wyłącz", - "set_preset_mode": "ustaw preset {preset_mode}", - "set_value": "ustaw wartość {value}", - "select_option": "wybierz opcję {option}", - "select_source": "wybierz źródło {source}", - "start": "start", - "run_script": "start" - }, - "service_parameters": { - "brightness": "jasność", - "temperature": "temperatura", - "position": "pozycja", - "hvac_mode": "tryb", - "preset_mode": "preset" - }, - "domains": { - "camera": "kamera", - "climate": "termostat", - "cover": "roleta", - "fan": "wentylator", - "group": "grupa", - "input_boolean": "wejście logiczne", - "input_number": "wejście liczbowe", - "input_select": "wybór wejścia", - "media_player": "odtwarzacz av", - "scene": "scena", - "light": "światło", - "switch": "włącznik", - "vacuum": "odkurzacz" - }, - "days": { - "tomorrow": "jutro", - "daily": "codziennie", - "daily_except_days": "codziennie za wyjątkiem {days}", - "working_days": "dni robocze", - "weekend": "weekend", - "interval": "{startDay} do {endDay}" - }, - "time": { - "absolute": "o {time}", - "relative": "za {time}", - "interval": "od {startTime} do {endTime}", - "seconds": "{seconds} sekund(a/y)", - "hour": "1 godzina", - "hours": "{hours} godzin(y)", - "minute": "1 minuta", - "minutes": "{minutes} minut(y)", - "now": "teraz", - "midnight": "północ", - "noon": "południe", - "at_sun_event": "o {sunEvent}", - "sun_event_sunrise": "wschodzie", - "sun_event_sunset": "zachodzie" - }, - "misc": { - "one_additional_task": "jeszcze 1 zadanie", - "x_additional_tasks": "{count} więcej zadań" - } -} \ No newline at end of file diff --git a/src/localize/languages/ro_old.json b/src/localize/languages/ro_old.json deleted file mode 100644 index b82bc78d..00000000 --- a/src/localize/languages/ro_old.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "scheduler": "Planificator", - "actions": { - "add": "adaugă element", - "cancel": "abandon", - "next": "următorul", - "save": "salvează", - "delete": "șterge" - }, - "instructions": { - "no_group_selected": "Prima dată selectați un grup", - "no_entity_selected": "Prima dată selectați o entitate", - "no_groups_defined": "Nu există grupuri definite", - "no_entities_for_group": "Nu există entități definite în acest grup", - "no_actions_for_entity": "Nu există acțiuni pentru această entitate", - "no_entries_defined": "Nu există elemente de afișat" - }, - "fields": { - "group": "Grup", - "entity": "Entitate", - "action": "Acțiune", - "days": "Zile", - "time": "Timp", - "options": "Opțiuni", - "day_type_daily": "zilnic", - "day_type_workday": "zile lucrătoare", - "day_type_weekend": "sfârșit de săptămână", - "day_type_custom": "personalizat" - }, - "days_short": { - "mon": "lun", - "tue": "mar", - "wed": "mie", - "thu": "joi", - "fri": "vin", - "sat": "sâm", - "sun": "dum" - }, - "days_long": { - "mon": "Luni", - "tue": "Marți", - "wed": "Miercuri", - "thu": "Joi", - "fri": "Vineri", - "sat": "Sâmbătă", - "sun": "Duminică" - }, - "words": { - "and": "și", - "before": "înainte", - "after": "după" - }, - "services": { - "turn_on": "pornire", - "turn_on_brightness": "pornire {la brightness}", - "turn_off": "oprire", - "close_cover": "închidere", - "open_cover": "deschidere", - "set_temperature": "setare temperatură {la temperature}", - "set_temperature_hvac_mode_heat": "încălzire {la temperature}", - "set_temperature_hvac_mode_cool": "răcire {la temperature}", - "set_cover_position": "setare poziție", - "set_hvac_mode": "setare mod {hvac_mode}", - "set_hvac_mode_hvac_mode_off": "oprire", - "set_preset_mode": "setare preset {preset_mode}", - "set_value": "setare valoare {value}", - "select_option": "selectare opțiune {option}", - "select_source": "selectare sursă {source}", - "start": "start", - "run_script": "rulare" - }, - "service_parameters": { - "brightness": "intensitate luminoasă", - "temperature": "temperatură", - "position": "poziție", - "hvac_mode": "mod", - "preset_mode": "preset" - }, - "domains": { - "camera": "camere", - "climate": "climat", - "cover": "jaluzele", - "fan": "ventilatoare", - "group": "grupuri", - "input_boolean": "input_boolean", - "input_number": "input_number", - "input_select": "input_select", - "light": "lumini", - "media_player": "media playere", - "scene": "scene", - "switch": "întrerupătpare", - "vacuum": "aspiratoare" - }, - "days": { - "tomorrow": "mâine", - "daily": "zilnic", - "daily_except_days": "zilnic cu excepția {days}", - "working_days": "zile lucrătoare", - "weekend": "sfârșit de săptămână", - "interval": "{startDay} până la {endDay}" - }, - "time": { - "absolute": "la {time}", - "relative": "în {time}", - "interval": "de la {startTime} la {endTime}", - "seconds": "{seconds} secunde", - "hour": "1 oră", - "hours": "{hours} ore", - "minute": "1 minut", - "minutes": "{minutes} minute", - "now": "acum", - "midnight": "miezul nopții", - "noon": "amiază", - "at_sun_event": "la {sunEvent}", - "sun_event_sunrise": "răsărit", - "sun_event_sunset": "apus" - }, - "misc": { - "one_additional_task": "încă o sarcină", - "x_additional_tasks": "încă {count} sarcini" - } -} \ No newline at end of file diff --git a/src/localize/languages/ru_old.json b/src/localize/languages/ru_old.json deleted file mode 100644 index 390f5155..00000000 --- a/src/localize/languages/ru_old.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "scheduler": "Планирование", - "actions": { - "add": "добавить", - "cancel": "отменить", - "next": "далее", - "save": "сохранить", - "delete": "удалить" - }, - "instructions": { - "no_group_selected": "Необходимо выбрать группу", - "no_entity_selected": "Необходимо выбрать объект", - "no_groups_defined": "Ни одной группы не создано", - "no_entities_for_group": "В этой группе нет объектов", - "no_actions_for_entity": "Для этого объекта нет действий", - "no_entries_defined": "Объекты отсутствуют" - }, - "fields": { - "group": "Группа", - "entity": "Объект", - "action": "Действие", - "days": "Дни", - "time": "Время", - "options": "Опции", - "day_type_daily": "ежедневно", - "day_type_workday": "по будням", - "day_type_weekend": "по выходным", - "day_type_custom": "выбрать дни" - }, - "days_short": { - "mon": "пн", - "tue": "вт", - "wed": "ср", - "thu": "чт", - "fri": "пт", - "sat": "сб", - "sun": "вс" - }, - "days_long": { - "mon": "понедельник", - "tue": "вторник", - "wed": "среда", - "thu": "четверг", - "fri": "пятница", - "sat": "суббота", - "sun": "воскресенье" - }, - "words": { - "and": "и", - "before": "до", - "after": "после" - }, - "services": { - "turn_on": "включить", - "turn_on_brightness": "включить {на brightness}", - "turn_off": "выключить", - "close_cover": "закрыть", - "open_cover": "открыть", - "set_temperature": "задать температуру {к temperature}", - "set_temperature_hvac_mode_heat": "обогрев {к temperature}", - "set_temperature_hvac_mode_cool": "охлаждение {к temperature}", - "set_cover_position": "установить позицию {position}", - "set_hvac_mode": "установить режим {hvac_mode}", - "set_hvac_mode_hvac_mode_off": "выключить", - "set_preset_mode": "выбрать набор настроек {preset_mode}", - "set_value": "установить значение {value}", - "select_option": "выбрать вариант {option}", - "select_source": "выбрать источник {source}", - "start": "запуск", - "run_script": "запустить" - }, - "service_parameters": { - "brightness": "Яркость", - "temperature": "Температура", - "position": "Позицию", - "hvac_mode": "режим", - "preset_mode": "предуставновлено" - }, - "domains": { - "camera": "Камеры", - "climate": "Климат", - "cover": "Жалюзи", - "fan": "Вентиляторы", - "group": "Группы", - "input_boolean": "Переключатели", - "input_number": "Числа", - "input_select": "Списки", - "media_player": "Медиаплееры", - "scene": "Сцены", - "light": "Освещение", - "switch": "Выключатели", - "vacuum": "Пылесосы" - }, - "days": { - "tomorrow": "завтра", - "daily": "ежедневно", - "daily_except_days": "каждый день исключая {days}", - "working_days": "рабочие дни", - "weekend": "выходные", - "interval": "{startDay} до {endDay}" - }, - "time": { - "absolute": "в {time}", - "relative": "через {time}", - "interval": "с {startTime} до {endTime}", - "seconds": "{seconds} секунд", - "hour": "1 час", - "hours": "{hours} часа", - "minute": "1 минуту", - "minutes": "{minutes} минут", - "now": "сейчас", - "midnight": "полночь", - "noon": "полдень", - "at_sun_event": "на {sunEvent}", - "sun_event_sunrise": "восходе", - "sun_event_sunset": "закате" - }, - "misc": { - "one_additional_task": "1 задача", - "x_additional_tasks": "{count} задач" - } -} diff --git a/src/localize/localize.ts b/src/localize/localize.ts index 0c23493f..11d8aa2f 100755 --- a/src/localize/localize.ts +++ b/src/localize/localize.ts @@ -37,8 +37,8 @@ const languages: any = { export function localize( string: string, lang: string, - search: string | string[] | number = '', - replace: string | string[] | number = '' + search: string | (string | number)[] | number = '', + replace: string | (string | number)[] | number = '' ) { let translated: string; try { @@ -54,16 +54,16 @@ export function localize( } if (search !== '' && replace !== '' && translated) { - if (Array.isArray(search) || Array.isArray(replace)) { - for (let i = 0; i < (search as string[]).length; i++) translated = translated.replace(search[i], replace[i]); - } else { + if (!Array.isArray(search)) search = [search]; + if (!Array.isArray(replace)) replace = [replace]; + for (let i = 0; i < (search as string[]).length; i++) { + translated = translated.replace(String(search[i]), String(replace[i])); const res = translated.match(/\{if ([a-z]+) is ([^\}]+)\}\ ?([^\{]+)\ ?\{else\}\ ?([^\{]+)/i); - if (res && String(search).replace(/[\{\}']+/g, '') == res[1]) { - const is_match = String(replace) == res[2]; + if (res && String(search[i]).replace(/[\{\}']+/g, '') == res[1]) { + const is_match = String(replace[i]) == res[2]; if (is_match) translated = translated.replace(res[0], res[3]); else translated = translated.replace(res[0], res[4]); } - translated = translated.replace(String(search), String(replace)); } }