Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locale_get_display_name no longer translates in the locale specified by the 2nd parameter #8656

Closed
gdejong opened this issue May 30, 2022 · 6 comments

Comments

@gdejong
Copy link

gdejong commented May 30, 2022

Description

The following code:

<?php

echo locale_get_display_name('ja', 'ja');

* with the intl extension installed

(https://www.php.net/manual/en/locale.getdisplayname.php)

Resulted in this output:

Japanese

But I expected this output instead:

日本語

This happens on PHP 8.1.6 while on 8.1.5 the correct output (translated in the locale specified by the second argument) gets returned.

PHP Version

PHP 8.1.6

Operating System

No response

@cmb69
Copy link
Contributor

cmb69 commented May 30, 2022

I cannot reproduce that; neither with ICU 68.2 nor with ICO 70.1. Do you use different ICU versions with your PHP 8.1.5 and 8.1.6? Which one(s)?

@gdejong
Copy link
Author

gdejong commented May 30, 2022

I should have added: I am running PHP in a Docker container (the cli-alpine version) and using mlocati/php-extension-installer to install the intl extension.

docker-compose.yml:

version: '3.5'
services:
  php:
    build:
      context: .
      dockerfile: Dockerfile
    working_dir: /opt/project
    volumes:
      - .:/opt/project

Dockerfile:

FROM php:8.1.6-cli-alpine

# Copy PHP Extension installer
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN chmod uga+x /usr/local/bin/install-php-extensions && install-php-extensions intl

test.php

<?php

echo "PHP Version: " . PHP_VERSION . PHP_EOL;

if (!extension_loaded("intl")) {
    die("missing intl extension");
}

echo locale_get_display_name("ja", "ja") . PHP_EOL;

Build the image:

docker-compose build

And run it:

docker-compose run --rm php php test.php

Regarding ICU versions:

php:8.1.6-cli-alpine is using 71.1
php:8.1.5-cli-alpine is using 69.1

(Checked that using docker-compose run --rm php php --re intl 2>&1 | grep INTL_ICU_VERSION)

@saundefined
Copy link
Member

ACK, followed the steps above:

PHP: 8.1.0, ICU: 69.1
日本語

PHP: 8.1.5, ICU: 69.1
日本語

PHP: 8.1.6, ICU: 71.1
Japanese

@cmb69
Copy link
Contributor

cmb69 commented May 30, 2022

Works for me even with ICU 71.1. I guess the the full data are not installed; try something like apk del icu-data-en && apk add icu-data-full. Would that solve the issue for you?

@gdejong
Copy link
Author

gdejong commented May 30, 2022

OK, the php:8.1.6-cli-alpine image uses Alpine Linux 3.16.0 (cat /etc/alpine-release) and they have split the ICU package in two.

See https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.16.0#ICU_data_split

image

We can install icu-data-full in our own build process as a workaround.

Is this something that the PHP alpine Docker images would want to include by default?

@cmb69
Copy link
Contributor

cmb69 commented May 30, 2022

Thanks for checking and reporting back!

Is this something that the PHP alpine Docker images would want to include by default?

You need to ask the provider of these packages (whoever that is) about that.

Anyhow, not a bug in php-src.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants