feat: export locale_display_pattern #272
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.
What are you trying to accomplish?
While CLDR contains translations of language names for simple locales in the
<languages>element, complex locales, such as a locale with a region, may not always have a specific translation in every language. For example,pt-BRhas a specific translation in English to "Brazilian Portuguese", but there is no specific translation for that locale in German.When a complex locale has no specific translation, CLDR specifies that we should use the patterns in
<localeDisplayPattern>to construct a display name out of the parts. The patterns are largely the same for most locales, but there are some slight differences, especially in choice of punctuation characters (half- vs full-width) for Asian languages, and use of spaces, so it's necessary to have separate patterns for each locale.ruby-cldr doesn't currently export the contents of
<localeDisplayPattern>, so projects cannot use ruby-cldr to consume these patterns through this library. At my team at Binti, we had to use cldr-json directly to get access to these patterns. I'd like to add support to export these patterns, so projects could use ruby-cldr instead....
What approach did you choose and why?
The approach in this PR is based on
Cldr::Export::Data::Languagesexporter.It generates a
locale_display_pattern.ymlfile with contents like the following:The keys are just the snake_case versions of the element names from CLDR.
...
What should reviewers focus on?
I think this is pretty straightforward, from a code perspective, but if it would be better to put this data in an existing file instead of a new one, I'm happy to change.
...
The impact of these changes
1 extra files per locale.
...
Testing
I made one test, to verify that the exporter creates the structure I expect for a given locale. If there's more testing that would be beneficial, I'm happy to add it.
...
Checklist