Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an option to verify translation key integrity in translation files #88

Open
navaronbracke opened this issue Sep 6, 2022 · 0 comments

Comments

@navaronbracke
Copy link

navaronbracke commented Sep 6, 2022

I have a question about the usage of intl_utils.

I recently had a bug where I thought that my translations were not being generated correctly.
Turns out that I had mismatching keys between translation files.
I.e.

intl_en.arb (128 entries)

"FirstKey": "foo",
"SecondKey": "bar"
"ThirdKey": "qux"
intl_fr.arb (128 entries)

"FirstKey": "foo",
"SecondWoopsKey": "bar"
"ThirdKey": "qux"

It took me a while to figure that out (especially with large translation files).
Would there be an option to have a validation check that is run before the translations are generated?
We could turn it on in the pubspec.yaml configuration.
All that the check would do is the following:

  1. Take the keys from the main translation file (the main_locale option)
  2. For each other translation file, verify that it has exactly the same set of keys
  3. If one or more files do not match the main translation file, exit with an error and perhaps show which files have conflicts and where

This would make it easier to spot the following errors:

  • missing keys in any translation file (works both ways I think)
  • the same amount of keys but different names (the issue I had earlier)

The errors could look like:

// missing translation in child translation file
File 'intl_fr.arb' does not have a translation for 'foo'. Either the key does not exist, or its name does not exactly match the one in main translation file 'intl_en.arb'

// translation in child translation file that does not yet exist in the main translation file
File 'intl_fr.arb' has a translation named 'bar' that does not yet exist in the main translation file 'intl_en.arb'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant