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

Increase strictness and improve ability to keep internationalization tests up-to-date #10508

Merged
merged 4 commits into from
Apr 25, 2024

Conversation

mitchellhenke
Copy link
Contributor

🛠 Summary of changes

While working on #10291, I was working on some improvements to the i18n tests and pulled them out here to make them easier to review. This PR makes a few changes:

  • Check whether keys in ALLOWED_UNTRANSLATED_KEYS are used in untranslated keys test. It's kind of goofy to mutate the hashes in the constant and check it in the same test, but it was straightforward. I'm very open to suggestions here.
  • Similar to above, check whether ALLOWED_INTERPOLATION_MISMATCH_KEYS are all used

The above will hopefully help in keeping the list of exceptions up-to-date.

I've also made some smaller changes to the checks in allowed_untranslated_key? so that we don't use a Regexp unless it is explicitly one, and otherwise use strict equality.

…tests up-to-date

changelog: Internal, Internationalization, Increase strictness and improve ability to keep internationalization tests up-to-date
@mitchellhenke mitchellhenke requested a review from a team April 25, 2024 16:53
@@ -68,15 +60,21 @@ def untranslated_key?(key, base_locale_value)
node = data[current_locale].first.children[key]
next unless node&.value&.is_a?(String)
next if node.value.empty?
next if allowed_untranslated_key?(current_locale, key)
node.value == base_locale_value
next unless node.value == base_locale_value
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swapped the conditionals here so that we only check whether a key is allowed to be untranslated in the case where we have a match on values. This removes some unnecessary checks and also helps with the tracking of unused allowed untranslated keys.

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/improve-i18n-test-strictness branch from f84d513 to 675e9ed Compare April 25, 2024 16:56
Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
@mitchellhenke mitchellhenke merged commit 947bbbf into main Apr 25, 2024
2 checks passed
@mitchellhenke mitchellhenke deleted the mitchellhenke/improve-i18n-test-strictness branch April 25, 2024 17:46
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

Successfully merging this pull request may close these issues.

2 participants