Welcome! Log In Create A New Profile

Advanced

[PHP-DEV] Preposition in IntlDateFormatter

Posted by Markus Fasselt 
Markus Fasselt
[PHP-DEV] Preposition in IntlDateFormatter
November 19, 2017 11:00PM
Hello internals,

I just noticed an issue with PHP's DateFormatter and some locales.

Consider this example code:

> foreach (['en', 'de', 'da', 'pt', 'fr', 'cs'] as $locale) {
> $df = new IntlDateFormatter($locale, IntlDateFormatter::LONG, IntlDateFormatter::SHORT);
> var_dump($locale . ': ' . $df->format(new DateTime()));
> }

which will output the following:

> string(33) "en: November 19, 2017 at 10:28 PM"
> string(30) "de: 19. November 2017 um 22:28"
> string(31) "da: 19. november 2017 kl. 22.28"
> string(32) "pt: 19 de novembro de 2017 22:28"
> string(29) "fr: 19 novembre 2017 à 22:28"
> string(28) "cs: 19. listopadu 2017 22:28"

As you can see, the first examples all have a preposition before the
time. But there is none for the Czech language - there should be a "v".

Some other languages are missing their prepositions as well, e.g. pl and
se (and probably more).

Is this a bug? I am no native speaker in these languages, but got a bug
report from a user and did some research. In my opinion, the
prepositions are missing.

Thanks,

Markus

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Derick Rethans
Re: [PHP-DEV] Preposition in IntlDateFormatter
November 20, 2017 11:10AM
On Sun, 19 Nov 2017, Markus Fasselt wrote:

> I just noticed an issue with PHP's DateFormatter and some locales.
>
> Consider this example code:
>
> > foreach (['en', 'de', 'da', 'pt', 'fr', 'cs'] as $locale) {
> > $df = new IntlDateFormatter($locale, IntlDateFormatter::LONG,
> > IntlDateFormatter::SHORT);
> > var_dump($locale . ': ' . $df->format(new DateTime()));
> > }
>
> which will output the following:
>
> > string(33) "en: November 19, 2017 at 10:28 PM"
> > string(30) "de: 19. November 2017 um 22:28"
> > string(31) "da: 19. november 2017 kl. 22.28"
> > string(32) "pt: 19 de novembro de 2017 22:28"
> > string(29) "fr: 19 novembre 2017 à 22:28"
> > string(28) "cs: 19. listopadu 2017 22:28"
>
> As you can see, the first examples all have a preposition before the time. But
> there is none for the Czech language - there should be a "v".
>
> Some other languages are missing their prepositions as well, e.g. pl and se
> (and probably more).
>
> Is this a bug? I am no native speaker in these languages, but got a bug report
> from a user and did some research. In my opinion, the prepositions are
> missing.

The information used for this is not part of the PHP source or code, but
comes out of ICU, which uses CLDR for its localisation information.

CLDR doesn't include the "v" for Cs.

From common/main/cs.xml:

<dateTimeFormats>
<dateTimeFormatLength type="full">
<dateTimeFormat>
<pattern>{1} {0}</pattern>

From common/main/de.xml:

<dateTimeFormats>
<dateTimeFormatLength type="full">
<dateTimeFormat>
<pattern>{1} 'um' {0}</pattern>

CLDR can be downloaded at http://cldr.unicode.org/index/downloads, and
bugs can be file at http://cldr.unicode.org/index/bug-reports

cheers,
Derick

--
https://derickrethans.nl | https://xdebug.org | https://dram.io
Like Xdebug? Consider a donation: https://xdebug.org/donate.php
twitter: @derickr and @xdebug
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Markus Fasselt
Re: [PHP-DEV] Preposition in IntlDateFormatter
November 22, 2017 10:40PM
Thank you Derick,

I will report it there.

Regards,

Markus


On 20.11.2017 11:03, Derick Rethans wrote:
> On Sun, 19 Nov 2017, Markus Fasselt wrote:
>
>> I just noticed an issue with PHP's DateFormatter and some locales.
>>
>> Consider this example code:
>>
>>> foreach (['en', 'de', 'da', 'pt', 'fr', 'cs'] as $locale) {
>>> $df = new IntlDateFormatter($locale, IntlDateFormatter::LONG,
>>> IntlDateFormatter::SHORT);
>>> var_dump($locale . ': ' . $df->format(new DateTime()));
>>> }
>>
>> which will output the following:
>>
>>> string(33) "en: November 19, 2017 at 10:28 PM"
>>> string(30) "de: 19. November 2017 um 22:28"
>>> string(31) "da: 19. november 2017 kl. 22.28"
>>> string(32) "pt: 19 de novembro de 2017 22:28"
>>> string(29) "fr: 19 novembre 2017 à 22:28"
>>> string(28) "cs: 19. listopadu 2017 22:28"
>>
>> As you can see, the first examples all have a preposition before the time. But
>> there is none for the Czech language - there should be a "v".
>>
>> Some other languages are missing their prepositions as well, e.g. pl and se
>> (and probably more).
>>
>> Is this a bug? I am no native speaker in these languages, but got a bug report
>> from a user and did some research. In my opinion, the prepositions are
>> missing.
>
> The information used for this is not part of the PHP source or code, but
> comes out of ICU, which uses CLDR for its localisation information.
>
> CLDR doesn't include the "v" for Cs.
>
> From common/main/cs.xml:
>
> <dateTimeFormats>
> <dateTimeFormatLength type="full">
> <dateTimeFormat>
> <pattern>{1} {0}</pattern>
>
> From common/main/de.xml:
>
> <dateTimeFormats>
> <dateTimeFormatLength type="full">
> <dateTimeFormat>
> <pattern>{1} 'um' {0}</pattern>
>
> CLDR can be downloaded at http://cldr.unicode.org/index/downloads, and
> bugs can be file at http://cldr.unicode.org/index/bug-reports
>
> cheers,
> Derick
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Sorry, only registered users may post in this forum.

Click here to login