php / php/php-src

Intl::composeLocale does not consider subtags

Abierto
#20,393 2 comentarios 0 reacciones 1 asignado Ver en GitHub

@devnexen ya está trabajando en esto.

Desde el 5/11/2025.

Extension: intl Feature Status: Verified
Lenguaje dominante
C
Estrellas
40.4k
Forks
8.1k
Merge medio
2 d 13 h
PR fusionados (30 d)
96

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.