Bug #79197 [Opn->Nab]: Intl class does not for some locales (maybe fallback option bug)
| From: | cmb@php.net | Date: | Tue, 14 Dec 2021 15:44:58 +0000 |
| Subject: | Bug #79197 [Opn->Nab]: Intl class does not for some locales (maybe fallback option bug) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-238404@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79197&edit=1
ID: 79197
Updated by: cmb@php.net
Reported by: salarmehr at gmail dot com
Summary: Intl class does not for some locales (maybe fallback
option bug)
-Status: Open
+Status: Not a bug
Type: Bug
Package: I18N and L10N related
Operating System: Windows/Linux
PHP Version: 7.3.14
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> Interestingly the [parent locale of
en_AU][1] is
> en_001.
Right, and that is an upstream issue, so consider to report
there[1].
[1] <https://unicode-org.atlassian.net/jira/software/c/projects/ICU/issues>
Previous Comments:
------------------------------------------------------------------------
[2020-01-30 09:36:03] salarmehr at gmail dot com
Description:
------------
Trying to get the language name from the language code, I run
```
$bundle = \ResourceBundle::create('en_UK', 'ICUDATA-lang', true);
$lang = $bundle->get('Languages')->get('fr');
var_dump($lang);
$bundle = \ResourceBundle::create('en_US', 'ICUDATA-lang', true);
$lang = $bundle->get('Languages')->get('fr');
var_dump($lang);
$bundle = \ResourceBundle::create('en_foobar', 'ICUDATA-lang', true);
$lang = $bundle->get('Languages')->get('fr');
var_dump($lang);
$bundle = \ResourceBundle::create('en_NZ', 'ICUDATA-lang', true);
$lang = $bundle->get('Languages')->get('fr');
var_dump($lang);
$bundle = \ResourceBundle::create('en_AU', 'ICUDATA-lang', true);
$lang = $bundle->get('Languages')->get('fr');
var_dump($lang);
```
```
string(6) "French"
string(6) "French"
string(6) "French"
NULL
NULL
```
It returns null for Australia and New Zealand that indicates an Intl error of
> Cannot load resource element 'fr': U_MISSING_RESOURCE_ERROR"
The third parameter of \ResourceBundle::create functions is for call back that means it
should fallback to its parent locale. Interestingly the [parent locale of en_AU][1] is
en_001.
Similarly, this happens for currency names
[1]: https://github.com/unicode-org/icu/blob/release-65-1/icu4c/source/data/lang/en_AU.txt
Test script:
---------------
$bundle = \ResourceBundle::create('en_AU', 'ICUDATA-lang', true);
$lang = $bundle->get('Languages')->get('fr');
var_dump($lang);
Expected result:
----------------
string(6) "French"
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79197&edit=1