question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Translation validation

See original GitHub issue

In 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
mpazikcommented, Apr 16, 2020

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.

1reaction
mpazikcommented, Apr 14, 2020

@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:

  • all declared ICU variables in translation exists in the source (translation can omit unused variables.
  • tags needs to have same structure as in the source file. That means
    • all of them are required
    • nesting of components have to be the same as in the source (<0>Hello<1/><0>)
    • the order of components can be different
    • if the tag is closed on the declaration (<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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Translation Validation for an Optimizing Compiler
We describe a translation validation infrastructure for the. GNU C compiler. During the compilation the infrastructure compares the intermediate form of the ...
Read more >
Translation validation | SpringerLink
We present the notion of translation validation as a new approach to the verification of translators (compilers, code generators).
Read more >
Translation Validation: Automatically Proving the Correctness ...
Definition: a means for proving for a given compiler (or any program translation procedure) for a high level language H and a low...
Read more >
Translation Validation for Medical Devices
Translation validation for medical devices is about ensuring that terminology and style are correct in the context of a particular device's usage. Even ......
Read more >
Translation Validation for the LLVM Compiler - INESC-ID
Keywords: Compilers - Software verification - Translation validation - Loop unroll - Refinement - ... 2.1 Compiler Verification and Translation Validation .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found