babel icon indicating copy to clipboard operation
babel copied to clipboard

Feature request: implement `pybabel lint`

Open jeanas opened this issue 2 years ago • 3 comments
trafficstars

A common error that translators do is translating the format field names, while they should remain untranslated. For example: translating "File {file} not found" by "Fichier {fichier} non trouvé" instead of "Fichier {file} non trouvé".

There is a script in this repository that checks for such errors: https://github.com/himdel/lint-po. However, it does its own PO file parsing that looks a bit fishy. I'd rather have this functionality in babel, with a well-tested PO parser.

jeanas avatar Jun 11 '23 21:06 jeanas

That would be much appreciated.

Quix0r avatar Aug 08 '23 11:08 Quix0r

Sounds like a great idea :)

akx avatar Oct 01 '23 09:10 akx

FYI we implemented something like this in Indico: https://github.com/indico/indico/blob/5167d8c065e04ca468764babeffd9f5287a3af60/indico/cli/i18n.py#L666-L686 It's implemented on top of babel so it could serve as an inspiration :)

We also have a checker for mismatched HTML tags (mostly for QA but also to automatically catch attempts to inject e.g. script tags via translation files): https://github.com/indico/indico/blob/5167d8c065e04ca468764babeffd9f5287a3af60/indico/cli/i18n.py#L689-L714

tomasr8 avatar Jul 25 '24 17:07 tomasr8