From 531c0738daab2d5f9b8324b85b45af7131aec0da Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 16 Oct 2009 17:42:27 +0000 Subject: 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. --- lib/util.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'lib/util.php') 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__); } -- cgit v1.2.3-54-g00ecf From b3c29800fbf7bd44f043e0c9742b207e15fb50f2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 16 Oct 2009 11:49:27 -0700 Subject: Drop a debug info line that isn't really needed --- lib/util.php | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/util.php') diff --git a/lib/util.php b/lib/util.php index 38147e998..d679d717f 100644 --- a/lib/util.php +++ b/lib/util.php @@ -64,7 +64,6 @@ function common_init_language() // 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"); -- cgit v1.2.3-54-g00ecf From 9d0e37c4e847f312c39eaf15deb95ff3777c13a6 Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Mon, 19 Oct 2009 13:11:55 -0400 Subject: Utilize NICKNAME_FMT constant when creating at replies --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/util.php') diff --git a/lib/util.php b/lib/util.php index 9b299cb14..047faeef0 100644 --- a/lib/util.php +++ b/lib/util.php @@ -391,7 +391,7 @@ function common_render_content($text, $notice) { $r = common_render_text($text); $id = $notice->profile_id; - $r = preg_replace('/(^|\s+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r); + $r = preg_replace('/(^|\s+)@(['.NICKNAME_FMT.']{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r); $r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r); $r = preg_replace('/(^|\s+)@#([A-Za-z0-9]{1,64})/e', "'\\1@#'.common_at_hash_link($id, '\\2')", $r); $r = preg_replace('/(^|\s)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r); -- cgit v1.2.3-54-g00ecf