summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2009-10-16 17:42:27 +0000
committerBrion Vibber <brion@pobox.com>2009-10-16 17:42:27 +0000
commit531c0738daab2d5f9b8324b85b45af7131aec0da (patch)
treec89880e24d1aaa913294c7ba984ad0fec4d1472e /lib
parent4ef0665408aee19d9ae69758e02fc98003e202ff (diff)
Workaround for not fully natively set up locales with native gettext...
Set "en_US" locale first, then the locale we want for our user. This seems to initialize gettext properly somehow, which I could see when the languages would come up briefly on settings save when changing from a supported language. Definitely works for ga_ES on my Ubuntu system (8.10 intrepid), hopefully reasonably consistent.
Diffstat (limited to 'lib')
-rw-r--r--lib/util.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/util.php b/lib/util.php
index 9b299cb14..38147e998 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -51,13 +51,24 @@ function common_init_locale($language=null)
function common_init_language()
{
mb_internal_encoding('UTF-8');
+
+ // gettext seems very picky... We first need to setlocale()
+ // to a locale which _does_ exist on the system, and _then_
+ // we can set in another locale that may not be set up
+ // (say, ga_ES for Galego/Galician) it seems to take it.
+ common_init_locale("en_US");
+
$language = common_language();
- // So we don't have to make people install the gettext locales
$locale_set = common_init_locale($language);
- bindtextdomain("statusnet", common_config('site','locale_path'));
+ setlocale(LC_CTYPE, 'C');
+
+ // So we don't have to make people install the gettext locales
+ $path = common_config('site','locale_path');
+ common_log(LOG_INFO, "binding text domain: $path");
+ bindtextdomain("statusnet", $path);
bind_textdomain_codeset("statusnet", "UTF-8");
textdomain("statusnet");
- setlocale(LC_CTYPE, 'C');
+
if(!$locale_set) {
common_log(LOG_INFO, 'Language requested:' . $language . ' - locale could not be set. Perhaps that system locale is not installed.', __FILE__);
}