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.
This commit is contained in:
parent
4ef0665408
commit
531c0738da
17
lib/util.php
17
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__);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user