From 1286b7ef065a8d4736523e0e43be054eda231f76 Mon Sep 17 00:00:00 2001 From: Ion Jaureguialzo Sarasola Date: Thu, 14 Feb 2019 14:52:40 +0100 Subject: [PATCH] Support for additional locales in PHP-FPM (#1976) --- DOCUMENTATION/content/documentation/index.md | 13 +++++++++++++ docker-compose.yml | 2 ++ env-example | 2 ++ php-fpm/Dockerfile | 16 ++++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/DOCUMENTATION/content/documentation/index.md b/DOCUMENTATION/content/documentation/index.md index 7795184d..af7f1956 100644 --- a/DOCUMENTATION/content/documentation/index.md +++ b/DOCUMENTATION/content/documentation/index.md @@ -1300,6 +1300,19 @@ We also recommend [setting the timezone in Laravel](http://www.camroncade.com/ma +
+ +## Add locales to PHP-FPM + +To add locales to the container: + +1 - Open the `.env` file and set `PHP_FPM_INSTALL_ADDITIONAL_LOCALES` to `true`. + +2 - Add locale codes to `PHP_FPM_ADDITIONAL_LOCALES`. + +3 - Re-build your PHP-FPM Container `docker-compose build php-fpm`. + +4 - Check enabled locales with `docker-compose exec php-fpm locale -a` diff --git a/docker-compose.yml b/docker-compose.yml index edba1edb..e9fb4c53 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -162,6 +162,8 @@ services: - INSTALL_IONCUBE=${PHP_FPM_INSTALL_IONCUBE} - INSTALL_APCU=${PHP_FPM_INSTALL_APCU} - INSTALL_YAML=${PHP_FPM_INSTALL_YAML} + - INSTALL_ADDITIONAL_LOCALES=${PHP_FPM_INSTALL_ADDITIONAL_LOCALES} + - ADDITIONAL_LOCALES=${PHP_FPM_ADDITIONAL_LOCALES} volumes: - ./php-fpm/php${PHP_VERSION}.ini:/usr/local/etc/php/php.ini - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG} diff --git a/env-example b/env-example index 641f71fc..5cb9254e 100644 --- a/env-example +++ b/env-example @@ -169,6 +169,8 @@ PHP_FPM_INSTALL_IONCUBE=false PHP_FPM_FAKETIME=-0 PHP_FPM_INSTALL_APCU=false PHP_FPM_INSTALL_YAML=false +PHP_FPM_INSTALL_ADDITIONAL_LOCALES=false +PHP_FPM_ADDITIONAL_LOCALES="es_ES.UTF-8 fr_FR.UTF-8" ### PHP_WORKER ############################################ diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index f9825f38..1e8800f1 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -585,6 +585,22 @@ RUN if [ ${INSTALL_YAML} = true ]; then \ docker-php-ext-enable yaml \ ;fi +########################################################################### +# Install additional locales: +########################################################################### + +ARG INSTALL_ADDITIONAL_LOCALES=false +ARG ADDITIONAL_LOCALES + +RUN if [ ${INSTALL_ADDITIONAL_LOCALES} = true ]; then \ + apt-get install -y locales \ + && echo '' >> /usr/share/locale/locale.alias \ + && temp="${ADDITIONAL_LOCALES%\"}" \ + && temp="${temp#\"}" \ + && for i in ${temp}; do sed -i "/$i/s/^#//g" /etc/locale.gen; done \ + && locale-gen \ +;fi + ########################################################################### # Check PHP version: ###########################################################################