Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Translator] Use ICU parent locales as fallback locales#28070

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromthewilkybarkid:icu-parent-locales
Aug 28, 2018

Conversation

@thewilkybarkid
Copy link
Contributor

@thewilkybarkidthewilkybarkid commentedJul 26, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#12319
LicenseMIT
Doc PRsymfony/symfony-docs#10122

Currently theTranslator fall backs based on the locale separator (eges_AR toes), but the ICU data contains parent locales (eges_AR is a child ofes_419, as ises_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 (eges_419 for Latin American Spanish), as well as adding other sensible fallbacks (eg Cape Verdean Portuguese topt_PT).

@thewilkybarkidthewilkybarkid changed the titleUse ICU parent locales as fallback locales[Translator] Use ICU parent locales as fallback localesJul 26, 2018

// Aliases contain the text "%%PARENT" followed by the aliased locale
if (\preg_match('/%%Parent{"([^"]+)"}/',$content,$matches)) {
if ('root' ===$matches[1]) {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I've just understood why some haveroot as a parent:az_Cyrl would fall back toaz (Azerbaijani in Latin) otherwise (so has a script change). Will update to stopaz being a fallback in this case.

protectedfunctioncomputeFallbackLocales($locale)
{
if (null ===$this->parentLocales) {
$parentLocales =\json_decode(\file_get_contents(__DIR__.'/Resources/data/parents.json'),true);
Copy link
Member

Choose a reason for hiding this comment

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

we don't fully-qualify all function calls in Symfony (to reduce the visual clutter). We only fully-qualify the function which can be optimized by the compiler (as the compiler cannot optimize them when it does not know for sure that the global function is the one being called)


$parentLocale =$parentLocales[$locale] ??null;

if ('root' ===$parentLocale) {
Copy link
Member

Choose a reason for hiding this comment

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

this is a BC break, as it removes some of the existing fallbacks.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Had a quick go and looks possible to keep track of deprecated fallbacks.

But this does raise a question of what should happen when the data changes, egCLDR 27 (egen_JE switched from falling back fromen_GB toen_001 directly).

Choose a reason for hiding this comment

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

I think we should follow CLDR

@nicolas-grekas
Copy link
Member

what's the lowest branch for this patch? bug fix should target the lowest maintained branch;

@thewilkybarkid
Copy link
ContributorAuthor

I'd describesr_Latn etc as bugs (fallbacks changing scripts), but did originally consider this a feature.

nicolas-grekas reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas added this to thenext milestoneAug 3, 2018
*
* @param string $sourceDir The directory with ICU files
*
* @return array An array with the locale as keys and the parent locales

Choose a reason for hiding this comment

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

the type annotations should be replaced by real PHP types

@thewilkybarkid
Copy link
ContributorAuthor

Looking at previous ICU updates, the data is merged into patch releases so future changes here will presumably do the same.

@fabpot
Copy link
Member

That's a new feature. Can you add a note in the CHANGELOG ?

@thewilkybarkid
Copy link
ContributorAuthor

Travis failure is unrelated.

@fabpot
Copy link
Member

Thank you@thewilkybarkid.

@fabpotfabpot merged commite0f402f intosymfony:masterAug 28, 2018
fabpot added a commit that referenced this pull requestAug 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#10122Currently 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
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestSep 4, 2018
…s (thewilkybarkid, javiereguiluz)This PR was merged into the master branch.Discussion----------Update translator fallback example to include ICU parentsChanges the example to showsymfony/symfony#28070.Commits-------7ccf603 Reworded and added the versionadded directive54631df Update translator fallback example to include ICU parents
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
This was referencedNov 3, 2018
@thewilkybarkidthewilkybarkid deleted the icu-parent-locales branchApril 7, 2019 14:02
nicolas-grekas added a commit that referenced this pull requestJun 30, 2020
…ator (jvasseur)This PR was merged into the 4.4 branch.Discussion----------[Translation] Fix caching of parent locales file in translator| Q             | A| ------------- | ---| Branch?       | 4.4 (this is the lowest maintained branch with this code)| Bug fix?      | yes| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets       || License       | MIT| Doc PR        |The `parentLocales` property was probably meant as a cache for the content of the `parents.json` file but instead the content is stored in a local variable and the property stays `null`. This means the file is read on each call to `computeFallbackLocales`.This PR update the code to what was probably meant to be.(Ref#28070)Commits-------02c9ac6 Fix caching of parent locales file in translator
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

5 participants

@thewilkybarkid@nicolas-grekas@fabpot@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp