[php-src] Issue #11864: INTL support BCP 47 U extension
| From: | frederikbosch | Date: | Wed, 02 Aug 2023 22:17:19 +0000 |
| Subject: | [php-src] Issue #11864: INTL support BCP 47 U extension | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245089@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11864
Author: frederikbosch
### Description
The following code:
```php
<?php
var_dump(\Locale::setDefault('en-US'));
$locale = \Locale::getDefault();
var_dump($locale);
$formatter = new \MessageFormatter($locale, '{0, time, medium}');
$result = $formatter->format([new \DateTime('now')]);
var_dump($result);
var_dump(\Locale::setDefault('en-US-u-hc-h23'));
$locale = \Locale::getDefault();
var_dump($locale);
$formatter = new \MessageFormatter($locale, '{0, time, medium}');
$result = $formatter->format([new \DateTime('now')]);
var_dump($result);
```
Resulted in this output:
```
bool(true)
string(5) "en-US"
string(11) "11:54:21 PM"
bool(true)
string(14) "en-US-u-hc-h23"
string(11) "11:54:21 PM"
```
But I expected this output instead:
```
bool(true)
string(5) "en-US"
string(11) "11:54:21 PM"
bool(true)
string(14) "en-US-u-hc-h23"
string(11) "23:54:21"
```
See also: https://3v4l.org/4udaJ.
In [the section on the Unicode BCP 47 U Extension of the Unicode Technical Standard
#35](https://www.unicode.org/reports/tr35/#u_Extension) you read that the U extension "provides
a mechanism for extending language tags for use in various applications by extension subtags".
I have no idea whether PHP supports this already. I guess this also depends on the operating system
and the version of the underlying ICU library. The test on my locale computer was executed on Alpine
3.18 with icu-data-full 73.2-r2 installed.
### PHP Version
PHP 8.x
### Operating System
Ubuntu, Alpine, any