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

Install system locales in web image #822

Closed
dahaupt opened this issue May 3, 2018 · 3 comments
Closed

Install system locales in web image #822

dahaupt opened this issue May 3, 2018 · 3 comments
Milestone

Comments

@dahaupt
Copy link

dahaupt commented May 3, 2018

What happened (or feature request):

I was using the method strftime('%B', mktime(0, 0, 0, 1, 1)) in PHP to format a date (here to get the month name), but unfortunately the month was not localized to German but English only, no matter if I changed the default locale in PHP with setlocale(LC_TIME, "de_DE") before.

What the method does:
strftime — Format a local time/date according to locale settings

What you expected to happen:

The method strftime should be able to use the systems locale to format any date correctly.

How to reproduce this:

Execute this snippet in any DDEV environment:

setlocale(LC_TIME, "de_DE");
$january = strftime('%B', mktime(0, 0, 0, 1, 1));
echo $january; // should print the german localized month name 'Januar' but shows 'January'

Version: Please include the output of ddev version, docker version and the project's .ddev/config.yaml.

cli     v0.17.0
web     drud/nginx-php-fpm-local:v1.2.2
db      drud/mariadb-local:v0.9.0
dba     drud/phpmyadmin:v0.2.0
router  drud/ddev-router:v0.5.0
commit  v0.17.0
domain  ddev.local

Anything else do we need to know:

The problem is based on the fact that no locales are installed in the web container except:

C
C.UTF-8
POSIX

My workaround was to use http://php.net/manual/en/class.intldateformatter.php to format the month name which works great without having any locale installed in the web container.

Related source links or issues:

http://php.net/manual/en/function.strftime.php

Please use a complexity rating of 1-5 (5 is high) for a feature request. (High complexity implies more PR planning)

1

@rfay
Copy link
Member

rfay commented May 3, 2018

Thanks for this request!

What's required to install the locales is apt-get update && apt-get install locales-all; we would need to add this in mariadb-local's list of packages.

For people who need this immediately, it can be done in any container with

docker exec -it -uroot ddev-<projectname>-web bash
apt-get update && apt-get install locales-all

This is lost on a ddev rm unfortunately.

@sbaghdadi
Copy link

+1 we should have and option in ddev-config to set the local. Because we need correct date settings in php.

@rfay
Copy link
Member

rfay commented Sep 13, 2018

@dahaupt @sbaghdadi I'd love it if you could test #1106, there are testing instructions there.

rfay added a commit to rfay/ddev that referenced this issue Sep 17, 2018
@rfay rfay closed this as completed in b992f6f Sep 18, 2018
@dclear dclear added this to the v1.3.0 milestone Oct 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants