summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-12-22 08:53:50 -0800
committerEvan Prodromou <evan@status.net>2009-12-22 08:53:50 -0800
commita2cb0a033fa6777d824dc40e759294287bd83939 (patch)
tree96b6947fd9aa7a76c1888a127e21e34319334f9b /lib
parentf17016470170401e1ad1b869c740063a578cb4cd (diff)
parentc9c316db7f003e018202e6c9f39770c208aecc05 (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'lib')
-rw-r--r--lib/language.php16
-rw-r--r--lib/util.php12
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/language.php b/lib/language.php
index d8f529201..f5ee7fac5 100644
--- a/lib/language.php
+++ b/lib/language.php
@@ -32,6 +32,21 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
+// Locale category constants are usually predefined, but may not be
+// on some systems such as Win32.
+$LC_CATEGORIES = array('LC_CTYPE',
+ 'LC_NUMERIC',
+ 'LC_TIME',
+ 'LC_COLLATE',
+ 'LC_MONETARY',
+ 'LC_MESSAGES',
+ 'LC_ALL');
+foreach ($LC_CATEGORIES as $key => $name) {
+ if (!defined($name)) {
+ define($name, $key);
+ }
+}
+
if (!function_exists('gettext')) {
require_once("php-gettext/gettext.inc");
}
@@ -283,6 +298,7 @@ function get_all_languages() {
'en' => array('q' => 1, 'lang' => 'en', 'name' => 'English (US)', 'direction' => 'ltr'),
'es' => array('q' => 1, 'lang' => 'es', 'name' => 'Spanish', 'direction' => 'ltr'),
'fi' => array('q' => 1, 'lang' => 'fi', 'name' => 'Finnish', 'direction' => 'ltr'),
+ 'fa' => array('q' => 1, 'lang' => 'fa', 'name' => 'Persian', 'direction' => 'rtl'),
'fr-fr' => array('q' => 1, 'lang' => 'fr', 'name' => 'French', 'direction' => 'ltr'),
'ga' => array('q' => 0.5, 'lang' => 'ga', 'name' => 'Galician', 'direction' => 'ltr'),
'he' => array('q' => 0.5, 'lang' => 'he', 'name' => 'Hebrew', 'direction' => 'rtl'),
diff --git a/lib/util.php b/lib/util.php
index af4885f40..ed81aeba1 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -91,8 +91,16 @@ function common_language()
if (_have_config() && common_logged_in()) {
$user = common_current_user();
$user_language = $user->language;
- if ($user_language)
- return $user_language;
+
+ if ($user->language) {
+ // Validate -- we don't want to end up with a bogus code
+ // left over from some old junk.
+ foreach (common_config('site', 'languages') as $code => $info) {
+ if ($info['lang'] == $user_language) {
+ return $user_language;
+ }
+ }
+ }
}
// Otherwise, find the best match for the languages requested by the