Translation validation
See original GitHub issueIn our team, we have a problem with the verification of translations. Sometimes translators do a typo in variable names or forgot to close a tag or mess up tags orders and nesting. If there is a problem in translation js lingui in production mode throws a fatal exception as it can not match variables to the translation and the page is not rendered. Which is really bad.
Right now we have a test parse source and translation for each language and compares but it’s not ideal.
It would be nice to have a built-in tool in js lingui CLI, something like lingui verify
or lingui compile --check
or be part of lingui compile --strict
I could contribute with PR adding this functionality. Please let me know if there is some other way to validate the translations that I missed and if not what is preferred way of implementing it from the CLI perspective 😃
This ticket could be related to https://github.com/lingui/js-lingui/issues/397 https://github.com/lingui/js-lingui/issues/4
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:9 (8 by maintainers)
I did some more investigation and I changed my mind. I think that any typo in the translation shouldn’t break the page in the runtime, perhaps it could cause a giltch in the dispalyed text like variable would be ignored or an extra tag would be displayed like
Hello <1>
.Some of the issues that used to break a page don’t break it any more. It will rise a bug for the remaining like using tag that does not exists or type in ICU types.
In the PR I’m going to introduce
lingui verify
that will check for obvious translator errors that would cause giltches in the UI (including current critial erros). Things that could be made on purpouse like ignoring variable, different component order or structure, will be allowed.@tricoder42 We load the source file (extracted translations) to memory and then compare translation agains it. Not sure if loading a file to memory is an issue. Our source file have less then 100KB but it think it should be fine up to like 100MB which is a lot of text. Not sure if there are such cases.
Regarding what exactly we do check:
<0>Hello<1/><0>
)<0/>
) in the source, companion tag is not allowed in translation also if the source tag had text, tags in translations also reqruie text.I could came up within few days with an initial PR so we could disuss exacat checks, the CLI API and implementation.