fix Norwegian and Dari hoc sync errors #31620
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Background
We've had a persistent issue with the HOC I18n sync wherein the YAML keys for Norwegian and Dari get malformed during the sync: 667045c
Both of these issues are a result of the fact that we were formerly using a regex to replace the top-level key provided by crowdin with one of our own:
code-dot-org/bin/i18n/hoc_sync_utils.rb
Lines 59 to 61 in 5d6a932
In the case of Norwegian, the problem was that the key
no:
is actually parsed by YAML as a boolean and not as a string, so we should be escaping that code like'no':
, but the regex doesn't know that.In the case of Dari, the problem is that the top-level key provided by crowdin is actually not the unique code (which for dari is
fa-AF
) but is actually just the two-letter language code, which in the case of Dari isfa
and which overlaps with the two-letter code for Persian.Fix
In both cases, the best fix is to actually parse the YAML, make our changes to the resulting data object, and then write the result back out to YAML.
Note that this will have a side effect of introducing formatting changes to the files. These files are YAML and there's no such thing as a consistent YAML format, so this is to be expected. Changes are mostly of the form of adding or removing quotes from strings. For example:
Links
Reviewer Checklist: