Merge branch 'master' of gitorious.org:statusnet/mainline into testing
This commit is contained in:
31
lib/util.php
31
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,14 @@ 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');
|
||||
@@ -97,6 +107,25 @@ function common_init_language()
|
||||
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');
|
||||
bindtextdomain("statusnet", $path);
|
||||
bind_textdomain_codeset("statusnet", "UTF-8");
|
||||
textdomain("statusnet");
|
||||
}
|
||||
|
||||
|
||||
function common_timezone()
|
||||
{
|
||||
if (common_logged_in()) {
|
||||
|
Reference in New Issue
Block a user