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

How do I install additional locales/languages? #1041

Closed
Dobbelklick opened this issue Jul 27, 2020 · 10 comments
Closed

How do I install additional locales/languages? #1041

Dobbelklick opened this issue Jul 27, 2020 · 10 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@Dobbelklick
Copy link

locale -a only has
C
C.UTF-8
POSIX

and I need something like de-DE to get proper formatting for my php website.

Or am I doing something wrong? I'm using setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu') but no matter what it returns, the language settings won't change.

@Dobbelklick
Copy link
Author

I don't see any way to tag this as a question instead of an issue. Sorry.

@wglambert
Copy link

From #359 (comment) the default LANG is C so changing that to C.UTF-8 allows it to see UTF-8 characters

$ docker run -it -e LC_ALL=C.UTF-8 -e LANG="de_DE@euro"--rm php bash

root@48fd94f8dfbc:/# mkdir Übersetzen

root@48fd94f8dfbc:/# touch Übersetzen/Grüße_Welt

root@48fd94f8dfbc:/# ls Übersetzen
Grüße_Welt

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Jul 27, 2020
@Dobbelklick
Copy link
Author

Dobbelklick commented Jul 27, 2020

Thanks, but I need to install language packs for PHP so that it properly supports spitting out "0,75" (COMMA) instead of "0.75" (DOT) when I "echo 3/4".

UTF8 characters haven't been a problem so far...

Or is this just how PHP works? US locale settings only?

What is setlocale() for then?

Should I use something else than docker/php for international websites?

@yosifkit
Copy link
Member

PHP probably just uses what libc provides. So, most likely you would need to install locales, update /etc/locale.gen via sed to uncomment out the locales you need, and then run locale-gen (https://wiki.archlinux.org/index.php/Locale)

@Dobbelklick
Copy link
Author

Neither locale.gen nor /etc/locale.gen are available in docker/php and I think that's because it is based on Alpine Linux and not Arch Linux.

I feel like I'm doing something massively wrong because I can't comprehend why it is so damn hard to get additional languages to work.

@yosifkit
Copy link
Member

Alpine doesn't really have support for locales (gliderlabs/docker-alpine#144). There are users in that thread and here that are adding some locales to Alpine, but I'm not certain that their methods will work in the future.

Alternatively you could just use the non-alpine images that are Debian based and just apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* to install locale-gen and /etc/locale.gen.

@Dobbelklick
Copy link
Author

Dobbelklick commented Jul 28, 2020

Okay, I'll try to find a php-fpm debian docker that runs on a Raspberry Pi. :(

Again though, am I using something wrong here? It feels like a massive oversight that docker/php with multiple millions of downloads isn't supporting locales.

@phy25
Copy link

phy25 commented Jul 30, 2020

Again though, am I using something wrong here? It feels like a massive oversight that docker/php with multiple millions of downloads isn't supporting locales.

If you read the comment again it's just that alpine doesn't support locales. This set of images has the Debian version as the default for these kind of customization reasons.

@Dobbelklick
Copy link
Author

Okay, I don't know what I did wrong until now, but I was under the impression that all docker/php images were alpine. Thank you for helping me out. I probably pulled the wrong images by accident.

@wglambert
Copy link

Closing since this seems resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

4 participants