|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-12-14 15:44 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2021-12-14 15:44 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 16:00:01 2025 UTC |
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