Small little annoyance we found in the process of internationalizing the site for European locales.
setlocale(LC_ALL, 'es_ES.UTF8'); // Spanish from spain $a = 1.2; echo 'hi'.$a;
This prints hi1,2. Take out the first line and it prints hi1.2 as you might expect.
Not a big deal right? Well imagine if that is the index into a cache key of an object? Now when someone from Spain views the page, it thinks those objects aren’t in cache. Big mess ensues.
I noticed that I suggested object versioning to be integers in the documentation, but some of us were using floats and I wasn’t type-checking. Whoops!
Our solution is to only set the locale when rendering output from a template and then setting it back. It’s ugly and I’m a definite fan of using integers only for version numbers in my next life.
Possesives
In a unrelated note, the people at work had a long discussion of how to render possessives when internationalizing. The key in the U.S. is to stop being clever and follow the first rule of the Elements of Style. This way it’s just,
printf(_('%s’s pictures'), htmlspecialchars($display_name));
Hopefully, the long argument I had trying to convince someone to do this will be returned in less neutered quotation marks on the site. I’m not holding my breath.
I’m using the same trick in the extranet I develop for my society.
However instead of using LC_ALL, you may want to surcharge LC_MONETARY and/or LC_NUMERIC.
http://www.manuelphp.com/php/function.setlocale.php
@FACORAT Fabrice: Good point that you don’t need to turn on every localization flag.