Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Intl] Load locale aliases to support alias fallbacks #26452

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

Closed

Conversation

jakzal
Copy link
Contributor

@jakzal jakzal commented Mar 8, 2018

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #21457
License MIT
Doc PR -

For example, zh_TW is an alias to zh_Hant_TW. Without aliases, zh_TW would fall back to zh (which is incorrect). With aliases loaded, zh_TW will fall back properly to zh_Hant_TW.

Judging by git history this has never worked.

\Locale::setDefault('zh'); dump(Intl::getRegionBundle()->getCountryName('AD'));
\Locale::setDefault('zh_TW'); dump(Intl::getRegionBundle()->getCountryName('AD'));
\Locale::setDefault('zh_Hant_TW'); dump(Intl::getRegionBundle()->getCountryName('AD'));

Before:

"安道尔"
"安道尔"
"安道爾"

After:

"安道尔"
"安道爾"
"安道爾"

All tests are passing, including those from the intl-data group.

jakzal added 2 commits March 7, 2018 23:32
For example, zh_TW is an alias to zh_Hant_TW. Without aliases, zh_TW would fall back to zh (which is incorrect). With aliases loaded, zh_TW will fall back properly to zh_Hant_TW.
Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

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

Although I don't understand the internals of this, the change looks correct, all test pass and the new test make sense to me. Thanks Jakub!

@jakzal
Copy link
Contributor Author

jakzal commented Mar 8, 2018

@javiereguiluz all our icu data providers use an entry reader to actually read icu data from (currently) json files we bundle with the intl component. The entry reader already supports handling aliases. However, we never told it to use any aliases. Now we do :)

jakzal added a commit that referenced this pull request Mar 9, 2018
…zal)

This PR was squashed before being merged into the 2.7 branch (closes #26452).

Discussion
----------

[Intl] Load locale aliases to support alias fallbacks

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21457
| License       | MIT
| Doc PR        | -

For example, `zh_TW` is an alias to `zh_Hant_TW`. Without aliases,` zh_TW` would fall back to `zh` (which is incorrect). With aliases loaded, `zh_TW` will fall back properly to `zh_Hant_TW`.

Judging by git history this has never worked.

```php
\Locale::setDefault('zh'); dump(Intl::getRegionBundle()->getCountryName('AD'));
\Locale::setDefault('zh_TW'); dump(Intl::getRegionBundle()->getCountryName('AD'));
\Locale::setDefault('zh_Hant_TW'); dump(Intl::getRegionBundle()->getCountryName('AD'));
```

Before:

```
"安道尔"
"安道尔"
"安道爾"
```

After:

```
"安道尔"
"安道爾"
"安道爾"
```

All tests are passing, including those from the `intl-data` group.

Commits
-------

1debf79 [Intl] Load locale aliases to support alias fallbacks
@jakzal jakzal closed this Mar 9, 2018
@jakzal jakzal deleted the bugfix/intl-locale-alias-resolution branch March 9, 2018 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants