summaryrefslogtreecommitdiff
path: root/lib/util.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-04-20 13:52:58 +0200
committerBrion Vibber <brion@pobox.com>2010-04-20 13:52:58 +0200
commitdf41287226d113f178ef66f320c8568566890fe9 (patch)
tree26cc4094f89dd76c1d95584c729ec4c32072610a /lib/util.php
parent056cce4b5eed28751bbad97e0dc826ee5310ff39 (diff)
parent61098faf5dd2685ea00c110bb4a3c871da17a300 (diff)
Merge branch 'testing' of gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'lib/util.php')
-rw-r--r--lib/util.php31
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/util.php b/lib/util.php
index b11bb06e3..81920eb44 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -41,11 +41,13 @@ function common_init_locale($language=null)
}
putenv('LANGUAGE='.$language);
putenv('LANG='.$language);
- return setlocale(LC_ALL, $language . ".utf8",
+ $ok = setlocale(LC_ALL, $language . ".utf8",
$language . ".UTF8",
$language . ".utf-8",
$language . ".UTF-8",
$language);
+
+ return $ok;
}
function common_init_language()
@@ -89,6 +91,32 @@ function common_init_language()
$locale_set = common_init_locale($language);
}
+ common_init_gettext();
+}
+
+/**
+ * @access private
+ */
+function common_init_gettext()
+{
+ setlocale(LC_CTYPE, 'C');
+ // So we do not have to make people install the gettext locales
+ $path = common_config('site','locale_path');
+ bindtextdomain("statusnet", $path);
+ bind_textdomain_codeset("statusnet", "UTF-8");
+ textdomain("statusnet");
+}
+
+/**
+ * Switch locale during runtime, and poke gettext until it cries uncle.
+ * Otherwise, sometimes it doesn't actually switch away from the old language.
+ *
+ * @param string $language code for locale ('en', 'fr', 'pt_BR' etc)
+ */
+function common_switch_locale($language=null)
+{
+ common_init_locale($language);
+
setlocale(LC_CTYPE, 'C');
// So we do not have to make people install the gettext locales
$path = common_config('site','locale_path');
@@ -97,6 +125,7 @@ function common_init_language()
textdomain("statusnet");
}
+
function common_timezone()
{
if (common_logged_in()) {