summaryrefslogtreecommitdiff
path: root/lib/util.php
diff options
context:
space:
mode:
authorCiaranG <ciaran@ciarang.com>2008-10-02 14:13:38 -0400
committerCiaranG <ciaran@ciarang.com>2008-10-02 14:13:38 -0400
commitb49c2f051a0d95ac280af0250e69215faee6018b (patch)
tree54e027a90c022cf1c11e46e1bd3f77fb87aed397 /lib/util.php
parent7f1639fda15161db0b0b5c6c10824d7d515123f1 (diff)
Combined language patches that got missed due to repo dependencies
darcs-hash:20081002181338-f6e2c-cf9cf3791680634fa457cb83dc2e4f933073a9b1.gz
Diffstat (limited to 'lib/util.php')
-rw-r--r--lib/util.php29
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/util.php b/lib/util.php
index 87c7f8fb0..cf514564e 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -146,6 +146,7 @@ function common_init_language() {
bind_textdomain_codeset("laconica", "UTF-8");
textdomain("laconica");
setlocale(LC_CTYPE, 'C');
+ common_log(LOG_INFO,'Language requested:'.$language.' Locale set:'.$locale_set,__FILE__);
}
define('PAGE_TYPE_PREFS', 'text/html,application/xhtml+xml,application/xml;q=0.3,text/xml;q=0.2');
@@ -483,25 +484,27 @@ function common_timezone() {
}
function common_language() {
- $httplang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : NULL;
- $language = array();
- $user_language = FALSE;
+ // If there is a user logged in and they've set a language preference
+ // then return that one...
if (common_logged_in()) {
$user = common_current_user();
$user_language = $user->language;
+ if ($user_language)
+ return $user_language;
}
- if ($user_language) {
- return $user_language;
- } else if (!empty($httplang)) {
- $language = client_prefered_language($httplang);
- if ($language) {
- return $language;
- }
- } else {
- return common_config('site', 'language');
- }
+ // Otherwise, find the best match for the languages requested by the
+ // user's browser...
+ $httplang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : NULL;
+ if (!empty($httplang)) {
+ $language = client_prefered_language($httplang);
+ if ($language)
+ return $language;
+ }
+
+ // Finally, if none of the above worked, use the site's default...
+ return common_config('site', 'language');
}
# salted, hashed passwords are stored in the DB