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

[Translator] Potential locale inheritance improvements #12319

Closed
thewilkybarkid opened this issue Oct 25, 2014 · 1 comment
Closed

[Translator] Potential locale inheritance improvements #12319

thewilkybarkid opened this issue Oct 25, 2014 · 1 comment

Comments

@thewilkybarkid
Copy link
Contributor

The translator currently (when not setting one) falls back to the locale one level higher (eg en_JE to en). ICU contains data where the parent should be different (eg en_JE > en_GB > en_001 to en). Has using this data to produce a fall-back map been considered?

This relates to misd-service-development/phone-number-bundle#22, where I'd like to be able to use es_419 (Latin American Spanish) to save having to have separate translations for each of the 20 sub-locales (according to the ICU data).

@thewilkybarkid
Copy link
Contributor Author

I've ended up using a compiler pass to mimic this (misd-service-development/phone-number-bundle#33).

fabpot added a commit that referenced this issue Aug 28, 2018
…s (thewilkybarkid)

This PR was squashed before being merged into the 4.2-dev branch (closes #28070).

Discussion
----------

[Translator] Use ICU parent locales as fallback locales

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #12319
| License       | MIT
| Doc PR        | symfony/symfony-docs#10122

Currently the `Translator` fall backs based on the locale separator (eg `es_AR` to `es`), but the ICU data contains parent locales (eg `es_AR` is a child of `es_419`, as is `es_BO`, `es_EC` etc).

This makes use of the ICU data to add add in these fallbacks. This means the specific locales can be used, but the translations can stored in these groupings (eg `es_419` for Latin American Spanish), as well as adding other sensible fallbacks (eg Cape Verdean Portuguese to `pt_PT`).

Commits
-------

e0f402f [Translator] Use ICU parent locales as fallback locales
@fabpot fabpot closed this as completed Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants