BitBoxSwiss / bitbox-wallet-app

The BitBoxApp for desktop and mobile.
https://bitbox.swiss/app
Apache License 2.0
251 stars 82 forks source link

ci: check that locize placeholders are the same in all languages #2738

Closed benma closed 2 months ago

benma commented 2 months ago

Translators sometimes accidentally translate {{placeholder}} variables, like "name"=>"nombre", breaking the translation.

This script checks that for each key in English (reference lang), all translations contain the same placeholders.

benma commented 2 months ago

CI fails with the expected errors in the locize files - we should probably fix all issues so make CI pass here, then merge to prevent future issues.

thisconnect commented 2 months ago

@benma please locize pull

benma commented 2 months ago

@thisconnect done

edit: current issues list:


Issues found in sl:
  - Placeholder mismatch at 'buy.info.disclaimer.protection.description': 'BitBoxApp ne zbira nobenih podatkov ob nakupu preko MoonPay. 
Prilivi se obravnavajo in so prikazani kot običajna transakcija. MoonPay za svoje delovanje zbira nekaj osebnih podatkov. Njihova politika zasebnosti podrobno pojasnjuje, kako ravna s temi podatki.' - found []; expected ['{{name}}']
Issues found in fr:
  - Placeholder mismatch at 'buy.info.disclaimer.protection.descriptionGeneric': 'BitBoxapp ne collecte aucune donnée lors de l'achat de {{nom}}, les fonds entrants sont traités comme une transaction normale. Cependant, les exchanges partenaires ont besoin de recueillir certaines informations pour fonctionner. Veuillez vous référer à leurs politiques de confidentialité respectives pour voir plus en détail comment sont traitées ces données.' - found ['{{nom}}']; expected ['{{name}}']
  - Placeholder mismatch at 'buy.pocket.usedAddress': 'L'adresse {{adresse}} a déjà été utilisée, veuillez recommencer avec une nouvelle adresse.' - found ['{{adresse}}']; expected ['{{address}}']
Issues found in fa:
  - Placeholder mismatch at 'bb02Bootloader.success': 'بروزرسانی با موفقیت انجام شد! ادامه در {{rebootSeconds}} ثانیه...' - found ['{{rebootSeconds}}']; expected []
  - Placeholder mismatch at 'notification.newTxs_one': '{{count}} معاملات جدید در: {{accountName}}' - found ['{{count}}', '{{accountName}}']; expected ['{{accountName}}']
Issues found in ar:
  - Placeholder mismatch at 'bb02Bootloader.success': 'التحديث تم بنجاح! سيتم الاستمرار خلال {{rebootSeconds}} ثانية...' - found ['{{rebootSeconds}}']; expected []
  - Placeholder mismatch at 'bb02Bootloader.success_install': 'التثبيت تم بنجاح! سيتم الاستمرار خلال {{rebootSeconds}} ثانية...' - found ['{{rebootSeconds}}']; expected []
Issues found in it:
  - Placeholder mismatch at 'password.warning.caps': 'per incollare il testo, attivare "MOSTRA {{etichetta}}"' - found ['{{etichetta}}']; expected []
Issues found in ja:
  - Placeholder mismatch at 'account.uncoveredFunds': '' - found []; expected ['{{name}}', '{{uncovered}}']
  - Placeholder mismatch at 'notification.newTxs_one': '{{accountName}}にて{{count}}個の新しいトランザクション' - found ['{{accountName}}', '{{count}}']; expected ['{{accountName}}']
Issues found in es:
  - Placeholder mismatch at 'connectKeystore.promptWithName': 'Por favor, conecta tu BitBox02 llamada "{{nombre}}" para continuar ' - found ['{{nombre}}']; expected ['{{name}}']
Issues found in he:
  - Placeholder mismatch at 'bb02Bootloader.success': '...עדכון צלח! ממשיך בעוד {{rebootSeconds}} שניות' - found ['{{rebootSeconds}}']; expected []
  - Placeholder mismatch at 'notification.newTxs_one': '{{count}} עסקה חדשה ב: {{accountName}}' - found ['{{count}}', '{{accountName}}']; expected ['{{accountName}}']
Issues found in zh:
  - Placeholder mismatch at 'notification.newTxs_one': '{{count}} 新交易: {{accountName}}' - found ['{{count}}', '{{accountName}}']; expected ['{{accountName}}']
thisconnect commented 2 months ago

thank you. fixed

benma commented 2 months ago

Thanks. One remaining:


+ ./scripts/check-locize-placeholders.py
Issues found in fa:
  - Placeholder mismatch at 'notification.newTxs_one': '{{count}} معاملات جدید در: {{accountName}}' - found ['{{count}}', '{{accountName}}']; expected ['{{accountName}}']
thisconnect commented 2 months ago

Thanks. One remaining:

oups 🙈 sorry, should be fixed now.

benma commented 2 months ago

Yeah it's fixed now, thanks.

baizon commented 2 months ago

Why was the scripts/check-locize-placeholders.py written in python? Why not Go, IMO it's not good to introduce another programming language. More complexity, more to maintain, etc.

thisconnect commented 2 months ago

Why not Go

or Node.js 😇

baizon commented 2 months ago

Indeed, because of frontends/web/src/locales/... I would locate it within Node and "frontend". Edit: Well, also bash + jq could do it, but yeah, that would be a more complex solution.

benma commented 2 months ago

Why was the scripts/check-locize-placeholders.py written in python? Why not Go, IMO it's not good to introduce another programming language. More complexity, more to maintain, etc.

Good point about another language, but it's available anyway in the Docker image.

Python felt like the best tool for the job - it's is kind of perfect for simple scripts like this imho. No strong opinion though, Go would have been fine too, but I don't think I'll re-do it now.

baizon commented 2 months ago

Yes, but like I said, then there is a Docker Python dependency. What if Python 4 is released and no more support for code fragments, etc. IMO the solution should be in Go, Node, or bash.

benma commented 2 months ago

Fyi, this is not the first Python script. ./scripts/get_version has been there since the beginning and is literally untouched since 5 years :grin: as a measure of how much of a maintenance burden it is.

Yes, but like I said, then there is a Docker Python dependency. What if Python 4 is released and no more support for code fragments, etc. IMO the solution should be in Go, Node, or bash.

I see your point, but these risks are not realistic imho. Python is available (has always been, will likely always be), Python 4 is not coming for many years if ever, breaking changes are very rare (not sure I ever experiences a breaking change in Python except 2->3). I really don't expect much Python-related maintenance overhead for this.