diff options
author | Brion Vibber <brion@pobox.com> | 2010-05-19 10:10:55 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-05-19 10:10:55 -0700 |
commit | 74a89b1fc37067d91d31bd66922053361eb4e616 (patch) | |
tree | 3c3520402e6d8c1a407af5d42e6c49abff5b7dd1 /lib/util.php | |
parent | 114df39822d7007f1b08b83b4e9a26202936e8c8 (diff) |
Locale switch cleanup: use common_switch_locale() which is safer for updating gettext state. Also moved a few calls to reduce chance of hitting an exception before switching back.
Should help with problems where xmppdaemon would get stuck in wrong locale.
Diffstat (limited to 'lib/util.php')
-rw-r--r-- | lib/util.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/util.php b/lib/util.php index efede1d4b..597da22c0 100644 --- a/lib/util.php +++ b/lib/util.php @@ -34,6 +34,14 @@ function common_user_error($msg, $code=400) $err->showPage(); } +/** + * This should only be used at setup; processes switching languages + * to send text to other users should use common_switch_locale(). + * + * @param string $language Locale language code (optional; empty uses + * current user's preference or site default) + * @return mixed success + */ function common_init_locale($language=null) { if(!$language) { @@ -50,6 +58,15 @@ function common_init_locale($language=null) return $ok; } +/** + * Initialize locale and charset settings and gettext with our message catalog, + * using the current user's language preference or the site default. + * + * This should generally only be run at framework initialization; code switching + * languages at runtime should call common_switch_language(). + * + * @access private + */ function common_init_language() { mb_internal_encoding('UTF-8'); |