aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-07-16 01:38:26 -0700
committerfriendica <info@friendica.com>2012-07-16 01:38:26 -0700
commitb79212dcc8849058e71b4fe51fae4898c4c81d14 (patch)
tree8ee059ddc60d82384b7a3ee77c997ae9e8b6e34b
parentc14845557047b949b550be752b92069a381fba71 (diff)
downloadvolse-hubzilla-b79212dcc8849058e71b4fe51fae4898c4c81d14.tar.gz
volse-hubzilla-b79212dcc8849058e71b4fe51fae4898c4c81d14.tar.bz2
volse-hubzilla-b79212dcc8849058e71b4fe51fae4898c4c81d14.zip
split up get_browser_language() to use in additional ways
-rwxr-xr-xinclude/items.php2
-rw-r--r--include/language.php14
-rw-r--r--index.php2
-rw-r--r--util/db_update.php2
4 files changed, 17 insertions, 3 deletions
diff --git a/include/items.php b/include/items.php
index 7ca53a3a0..81e92d588 100755
--- a/include/items.php
+++ b/include/items.php
@@ -827,6 +827,8 @@ function item_store($arr,$force_parent = false) {
$arr['body'] = strip_tags($arr['body']);
$arr['lang'] = detect_language($arr['body']);
+
+
$arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0);
diff --git a/include/language.php b/include/language.php
index 9cde82903..f43b7e179 100644
--- a/include/language.php
+++ b/include/language.php
@@ -19,6 +19,8 @@
if(! function_exists('get_browser_language')) {
function get_browser_language() {
+ $langs = array();
+
if (x($_SERVER,'HTTP_ACCEPT_LANGUAGE')) {
// break up string into pieces (languages and q factors)
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i',
@@ -37,6 +39,16 @@ function get_browser_language() {
arsort($langs, SORT_NUMERIC);
}
}
+ else
+ $langs['en'] = 1;
+
+ return $langs;
+}}
+
+
+function get_best_language() {
+
+ $langs = get_browser_language();
if(isset($langs) && count($langs)) {
foreach ($langs as $lang => $v) {
@@ -52,7 +64,7 @@ function get_browser_language() {
$a = get_app();
return ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
-}}
+}
function push_lang($language) {
diff --git a/index.php b/index.php
index f4c92cc5f..bcad5f607 100644
--- a/index.php
+++ b/index.php
@@ -27,7 +27,7 @@ $install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false
@include(".htconfig.php");
-$lang = get_browser_language();
+$lang = get_best_language();
load_translation_table($lang);
diff --git a/util/db_update.php b/util/db_update.php
index 978594ab9..775a6585a 100644
--- a/util/db_update.php
+++ b/util/db_update.php
@@ -11,7 +11,7 @@ require_once("boot.php");
$a = new App;
@include(".htconfig.php");
-$lang = get_browser_language();
+$lang = get_best_language();
load_translation_table($lang);
require_once("dba.php");