From c48caa85e12063c2df9913957dbd11af6b5e3ea6 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 20 Apr 2010 12:06:54 +0200 Subject: Fix email notifications for @-replies that come via OStatus. * Moved notification sending from Notice::saveReplies to distrib queue handler, so it'll pull from the reply set we've saved regardless of how we got it. * Set up gettext infrastructure for command-line scripts; gets localization mail notifications etc working from background queues. * Adjusted locale switching: common_switch_locale() works at runtime for bg scripts, forces a message catalog update --- lib/util.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'lib/util.php') diff --git a/lib/util.php b/lib/util.php index e37df6348..58d54cda3 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()) { -- cgit v1.2.3-54-g00ecf From c78a10b476bb6d84e4056038fea1b8185d20ef46 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 21 Apr 2010 17:14:25 -0400 Subject: add 'always' parameter to common_shorten_links --- lib/util.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/util.php') diff --git a/lib/util.php b/lib/util.php index 81920eb44..e0669a1d5 100644 --- a/lib/util.php +++ b/lib/util.php @@ -855,10 +855,10 @@ function common_linkify($url) { return XMLStringer::estring('a', $attrs, $url); } -function common_shorten_links($text) +function common_shorten_links($text, $always = false) { $maxLength = Notice::maxContent(); - if ($maxLength == 0 || mb_strlen($text) <= $maxLength) return $text; + if (!$always && ($maxLength == 0 || mb_strlen($text) <= $maxLength)) return $text; return common_replace_urls_callback($text, array('File_redirection', 'makeShort')); } -- cgit v1.2.3-54-g00ecf