alterway / docker-php

Docker PHP
MIT License
99 stars 45 forks source link

How to install localization? #8

Closed alexislefebvre closed 5 years ago

alexislefebvre commented 7 years ago

I'm using PHP-CLI 5.4 but localizations are missing in the container.

Heres is my docker-compose.yml:

php-5.4:
  image: alterway/php:5.4-cli
  container_name: php-5.4
  environment:
    PHP__display_errors: 'On'
    PHP__opcache.enable: 'Off'
    PHP__memory_limit:   '128M'
    PHP__post_max_size:  '50M'
    PHP__date.timezone:  '"Europe/Paris"'
    PHP_php5enmod: 'intl pdo_mysql'
  user: '1000'
  volumes:
    - /etc/passwd:/etc/passwd:ro
    - $PWD:$PWD
  working_dir: $PWD
  command: "myscript.php"

And the myscript.php file:

<?php

system('locale -a');
setlocale(LC_ALL, 'fr_FR.UTF8');
echo(strftime('%A %d %B %Y'));

And the output where the date is not localized:

$ docker-compose up
Recreating php-5.4
Attaching to php-5.4
php-5.4    | C
php-5.4    | C.UTF-8
php-5.4    | POSIX
php-5.4    | Sunday 30 July 2017php-5.4 exited with code 0

When I run the script locally I have the correct localization:

$ php myscript.php
C
C.UTF-8
de_DE.utf8
en_AG
en_AG.utf8
en_AU.utf8
[…]
fr_CH.utf8
fr_FR.utf8
fr_LU.utf8
POSIX
dimanche 30 juillet 2017⏎

How can I install the french locale in the container?

alexislefebvre commented 5 years ago

It was due to a bad configuration in my Symfony command.

But it may also require to reinstall the intl again: https://github.com/alexislefebvre/docker-images/blob/e7cb6593dd4a35601a50fe0c25c40e3ca42750fc/5.4-composer/Dockerfile#L19