linux locales to freebsd: symlink to make php setlocale() happy
olli at lurza.secnetix.de
Thu Nov 16 06:27:06 PST 2006
Olivier Mueller wrote:
> While moving some more customers from a linux to a freebsd-based
> hosting, like some others I had a problem with php pages using
> According to 'locale -a', it looks like that for de_DE (german):
> Linux (suse):
> de_DE at euro
> FreeBSD (6.1):
There's no standard for locale names (and it shouldn't be
> And in the customers code, the call which hadn't worked anymore is:
> setlocale (LC_ALL, 'de_DE at euro', 'de_DE', 'de', 'ge').
It's bad design to hardcode locale names in programs. It's
much better (and standard practice) to pick up the locale
from the environment variables, so they can be configured
in the environment, without having to hack the program.
> I could tell the customer to update his code and add "de_DE.ISO8859-1"
> to his setlocale() list,
You could also tell the customer to fix that crap and use
environment variables. :-)
> but he will ask me "why isn't it like before?"
The answer is "because your program was written in a non-
portable way and needs to be fixed".
> So what would be the "cleanest" solution?
The cleanest solution is certainly to fix the program.
> Is there an options somewhere
> to add the "standard" de_DE-like label (xx_XX) to all languages?
Not that I'm aware of. It's not a standard anyway, and
I even consider it bad practice because the character set
specification is missing, so it's ambiguous.
> Or should I use symlinks like:
> [root at bsd /usr/share/locale]# ln -s de_DE.ISO8859-1 de_DE
Well, that would be a work-around that should work.
It's not really a "clean solution", though.
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.
"If you aim the gun at your foot and pull the trigger, it's
UNIX's job to ensure reliable delivery of the bullet to
where you aimed the gun (in this case, Mr. Foot)."
-- Terry Lambert, FreeBSD-hackers mailing list.
More information about the freebsd-stable