Skip to content

Commit 1286b7e

Browse files
ijaureguialzobestlong
authored andcommitted
Support for additional locales in PHP-FPM (laradock#1976)
1 parent e0d7229 commit 1286b7e

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

DOCUMENTATION/content/documentation/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,19 @@ We also recommend [setting the timezone in Laravel](http://www.camroncade.com/ma
13001300

13011301

13021302

1303+
<br>
1304+
<a name="Add locales to PHP-FPM"></a>
1305+
## Add locales to PHP-FPM
1306+
1307+
To add locales to the container:
1308+
1309+
1 - Open the `.env` file and set `PHP_FPM_INSTALL_ADDITIONAL_LOCALES` to `true`.
1310+
1311+
2 - Add locale codes to `PHP_FPM_ADDITIONAL_LOCALES`.
1312+
1313+
3 - Re-build your PHP-FPM Container `docker-compose build php-fpm`.
1314+
1315+
4 - Check enabled locales with `docker-compose exec php-fpm locale -a`
13031316

13041317

13051318

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ services:
162162
- INSTALL_IONCUBE=${PHP_FPM_INSTALL_IONCUBE}
163163
- INSTALL_APCU=${PHP_FPM_INSTALL_APCU}
164164
- INSTALL_YAML=${PHP_FPM_INSTALL_YAML}
165+
- INSTALL_ADDITIONAL_LOCALES=${PHP_FPM_INSTALL_ADDITIONAL_LOCALES}
166+
- ADDITIONAL_LOCALES=${PHP_FPM_ADDITIONAL_LOCALES}
165167
volumes:
166168
- ./php-fpm/php${PHP_VERSION}.ini:/usr/local/etc/php/php.ini
167169
- ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG}

env-example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ PHP_FPM_INSTALL_IONCUBE=false
169169
PHP_FPM_FAKETIME=-0
170170
PHP_FPM_INSTALL_APCU=false
171171
PHP_FPM_INSTALL_YAML=false
172+
PHP_FPM_INSTALL_ADDITIONAL_LOCALES=false
173+
PHP_FPM_ADDITIONAL_LOCALES="es_ES.UTF-8 fr_FR.UTF-8"
172174

173175
### PHP_WORKER ############################################
174176

php-fpm/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,22 @@ RUN if [ ${INSTALL_YAML} = true ]; then \
585585
docker-php-ext-enable yaml \
586586
;fi
587587

588+
###########################################################################
589+
# Install additional locales:
590+
###########################################################################
591+
592+
ARG INSTALL_ADDITIONAL_LOCALES=false
593+
ARG ADDITIONAL_LOCALES
594+
595+
RUN if [ ${INSTALL_ADDITIONAL_LOCALES} = true ]; then \
596+
apt-get install -y locales \
597+
&& echo '' >> /usr/share/locale/locale.alias \
598+
&& temp="${ADDITIONAL_LOCALES%\"}" \
599+
&& temp="${temp#\"}" \
600+
&& for i in ${temp}; do sed -i "/$i/s/^#//g" /etc/locale.gen; done \
601+
&& locale-gen \
602+
;fi
603+
588604
###########################################################################
589605
# Check PHP version:
590606
###########################################################################

0 commit comments

Comments
 (0)