Skip to content

Commit

Permalink
fix(translations): fix invalid translation using single {}, add escap…
Browse files Browse the repository at this point in the history
…ing with {{}}
  • Loading branch information
sogehige committed Jan 6, 2025
1 parent 36899cd commit 4ca6ae7
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 27 deletions.
4 changes: 2 additions & 2 deletions locales/ar/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Message template",
"placeholder": "Set your message template",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "TTS template",
"placeholder": "Set your TTS template",
"help": "Available variables: {name}, {amount} {monthsName} {currency} {message}"
"help": "Available variables: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Animation text"
Expand Down
4 changes: 2 additions & 2 deletions locales/cs/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Šablona zprávy",
"placeholder": "Zadejte svou šablonu zprávy",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "TTS šablona",
"placeholder": "Nastavte si šablonu TTS",
"help": "Dostupné proměnné: {name}, {amount} {monthsName} {currency} {message}"
"help": "Dostupné proměnné: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Animace textu"
Expand Down
4 changes: 2 additions & 2 deletions locales/da/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Message template",
"placeholder": "Set your message template",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "TTS template",
"placeholder": "Set your TTS template",
"help": "Available variables: {name}, {amount} {monthsName} {currency} {message}"
"help": "Available variables: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Animation text"
Expand Down
4 changes: 2 additions & 2 deletions locales/de/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Nachrichtenvorlage",
"placeholder": "Nachrichtenvorlage festlegen",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "TTS Vorlage",
"placeholder": "TTS-Vorlage festlegen",
"help": "Verfügbare Variablen: {name}, {amount} {monthsName} {currency} {message}"
"help": "Verfügbare Variablen: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Animationstext"
Expand Down
4 changes: 2 additions & 2 deletions locales/en/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Message template",
"placeholder": "Set your message template",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "TTS template",
"placeholder": "Set your TTS template",
"help": "Available variables: {name}, {amount} {monthsName} {currency} {message}"
"help": "Available variables: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Animation text"
Expand Down
4 changes: 2 additions & 2 deletions locales/es/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Message template",
"placeholder": "Set your message template",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "TTS template",
"placeholder": "Set your TTS template",
"help": "Available variables: {name}, {amount} {monthsName} {currency} {message}"
"help": "Available variables: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Animation text"
Expand Down
4 changes: 2 additions & 2 deletions locales/fr/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Modèle de message",
"placeholder": "Mettez votre modèle de message",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "TTS template",
"placeholder": "Set your TTS template",
"help": "Available variables: {name}, {amount} {monthsName} {currency} {message}"
"help": "Available variables: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Animation du texte"
Expand Down
4 changes: 2 additions & 2 deletions locales/it/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Modello messaggio",
"placeholder": "Imposta il tuo modello di messaggi",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "TTS template",
"placeholder": "Set your TTS template",
"help": "Available variables: {name}, {amount} {monthsName} {currency} {message}"
"help": "Available variables: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Testo animazione"
Expand Down
4 changes: 2 additions & 2 deletions locales/ja/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Message template",
"placeholder": "Set your message template",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "TTS template",
"placeholder": "Set your TTS template",
"help": "Available variables: {name}, {amount} {monthsName} {currency} {message}"
"help": "Available variables: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Animation text"
Expand Down
4 changes: 2 additions & 2 deletions locales/nb/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Meldingsmal",
"placeholder": "Angi din meldingsmal",
"help": "Tilgjengelige variabler: {name}, {amount} (cheers, abonnement, tips, abonnementsgaver, abonnementsgaver til fellesskapet, innløste kommandoer), {recipient} (abonnementsgaver, innløste kommandoer), {monthsName} (abonnement, abonnementsgaver), {tier} (abonnement), {currency} (tips), {game} (promo). Hvis | legges til (se promo) så vil de verdiene vises i rekkefølge."
"help": "Tilgjengelige variabler: {{name}}, {{amount}} (cheers, abonnement, tips, abonnementsgaver, abonnementsgaver til fellesskapet, innløste kommandoer), {{recipient}} (abonnementsgaver, innløste kommandoer), {{monthsName}} (abonnement, abonnementsgaver), {{tier}} (abonnement), {{currency}} (tips), {{game}} (promo). Hvis | legges til (se promo) så vil de verdiene vises i rekkefølge."
},
"ttsTemplate": {
"name": "TTS mal",
"placeholder": "Angi din TTS mal",
"help": "Tilgjengelige variabler: {name}, {amount} {monthsName} {currency} {message}"
"help": "Tilgjengelige variabler: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Animasjonstekst"
Expand Down
4 changes: 2 additions & 2 deletions locales/pt/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Modelo de mensagem",
"placeholder": "Defina o seu modelo de mensagem",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "Modelos TTS",
"placeholder": "Defina seu modelo de TTS",
"help": "Variáveis disponíveis: {name}, {amount} {monthsName} {currency} {message}"
"help": "Variáveis disponíveis: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Texto de animação"
Expand Down
4 changes: 2 additions & 2 deletions locales/ru/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Шаблон сообщения",
"placeholder": "Установить шаблон сообщения",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "Шаблон TTS",
"placeholder": "Установить шаблон TTS",
"help": "Доступные переменные: {name}, {amount} {monthsName} {currency} {message}"
"help": "Доступные переменные: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Текст анимации"
Expand Down
4 changes: 2 additions & 2 deletions locales/uk/ui/registry/alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@
"messageTemplate": {
"name": "Message template",
"placeholder": "Set your message template",
"help": "Available variables: {name}, {amount} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {recipient} (subgifts, command redeems), {monthsName} (subs, subgifts), {tier} (subs), {currency} (tips), {game} (promo). If | is added (see promo) then it will show those values in sequence."
"help": "Available variables: {{name}}, {{amount}} (cheers, subs, tips, subgifts, sub community gifts, command redeems), {{recipient}} (subgifts, command redeems), {{monthsName}} (subs, subgifts), {{tier}} (subs), {{currency}} (tips), {{game}} (promo). If | is added (see promo) then it will show those values in sequence."
},
"ttsTemplate": {
"name": "TTS template",
"placeholder": "Set your TTS template",
"help": "Available variables: {name}, {amount} {monthsName} {currency} {message}"
"help": "Available variables: {{name}}, {{amount}} {{monthsName}} {{currency}} {{message}}"
},
"animationText": {
"name": "Animation text"
Expand Down
5 changes: 4 additions & 1 deletion src/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,12 @@ class Translations extends Core {
} else {
translated = get(this.translations[getLang()], String(text), undefined);
}
each(translated.match(/(\{[\w-.]+\})/g), (toTranslate) => {
// translate {something} but not {{something}}
each(translated.match(/(?<!\{)\{[\w-.]+\}(?!\})/g), (toTranslate) => {
translated = translated.replace(toTranslate, this.get(toTranslate.replace('{', '').replace('}', ''), orig));
});
// replace {{something}} to {something}
translated = translated.replace(/\{\{([\w-.]+)\}\}/g, '{$1}');
return translated;
} catch (err: any) {
return '{missing_translation: ' + getLang() + '.' + String(text) + '}';
Expand Down

0 comments on commit 4ca6ae7

Please sign in to comment.