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

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

Closed

Conversation

@jakzal
Copy link
Member

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 Mar 7, 2018
[Intl] Load locale aliases to support alias fallbacks
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.
@javiereguiluz
Copy link
Member

left a comment

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

This comment has been minimized.

Copy link
Member Author

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 :)

@fabpot
fabpot approved these changes Mar 8, 2018
jakzal added a commit that referenced this pull request Mar 9, 2018
bug #26452 [Intl] Load locale aliases to support alias fallbacks (jak…
…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 jakzal:bugfix/intl-locale-alias-resolution branch Mar 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.