Intl::composeLocale does not consider subtags
Đang mở
@devnexen đang làm issue này rồi.
Từ ngày 5/11/2025.
Extension: intl
Feature
Status: Verified
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
Description
The following code:
<?php
$first = 'en_US@timezone=Europe/Amsterdam';
$second = 'nl_NL';
var_dump(\Locale::parseLocale($first));
var_dump(\Locale::getKeywords($first));
var_dump(\Locale::parseLocale($second));
var_dump(\Locale::getKeywords($second));
$merged = [
...\Locale::parseLocale($first),
...\Locale::getKeywords($first) ?? [],
...\Locale::parseLocale($second),
...\Locale::getKeywords($second) ?? [],
];
var_dump($merged);
var_dump(\Locale::composeLocale($merged));
$newSynax = 'en_US-u-tz-nlams';
var_dump(\Locale::parseLocale($newSynax));
var_dump(\Locale::getKeywords($newSynax));
Resulted in this output:
array(2) {
["language"]=>
string(2) "en"
["region"]=>
string(2) "US"
}
array(1) {
["timezone"]=>
string(16) "Europe/Amsterdam"
}
array(2) {
["language"]=>
string(2) "nl"
["region"]=>
string(2) "NL"
}
NULL
array(3) {
["language"]=>
string(2) "nl"
["region"]=>
string(2) "NL"
["timezone"]=>
string(16) "Europe/Amsterdam"
}
string(5) "nl_NL"
array(2) {
["language"]=>
string(2) "en"
["region"]=>
string(2) "US"
}
NULL
But I expected this output instead:
array(2) {
["language"]=>
string(2) "en"
["region"]=>
string(2) "US"
}
array(1) {
["timezone"]=>
string(16) "Europe/Amsterdam"
}
array(2) {
["language"]=>
string(2) "nl"
["region"]=>
string(2) "NL"
}
NULL
array(3) {
["language"]=>
string(2) "nl"
["region"]=>
string(2) "NL"
["timezone"]=>
string(16) "Europe/Amsterdam"
}
string(5) "nl_NL@timezone=Europe/Amsterdam"
array(2) {
["language"]=>
string(2) "en"
["region"]=>
string(2) "US"
}
array(1) {
["timezone"]=>
string(16) "Europe/Amsterdam"
}
The reasoning behind this, as the example shows, is that I try to activate a new language and region while maintaining the other subtags.
PHP Version
PHP 8.2-8.5 and master
Operating System
No response
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Đánh giá
Issue này chưa được đánh giá.