summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
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