diff options
author | mrjive <mrjive@mrjive.it> | 2018-01-26 09:43:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-26 09:43:47 +0100 |
commit | 4b7967b938f65137b889fc172c957345680bfc11 (patch) | |
tree | 94b5f1882110f92cf83b8e9185295a8206a9ebeb /include/language.php | |
parent | f560a3c98fc7cf4de7d86bd7f074c9995b3d240a (diff) | |
parent | 4656856dfbf41e855b1bb8625290c07a5dcf8d38 (diff) | |
download | volse-hubzilla-4b7967b938f65137b889fc172c957345680bfc11.tar.gz volse-hubzilla-4b7967b938f65137b889fc172c957345680bfc11.tar.bz2 volse-hubzilla-4b7967b938f65137b889fc172c957345680bfc11.zip |
Merge pull request #12 from redmatrix/dev
Dev
Diffstat (limited to 'include/language.php')
-rw-r--r-- | include/language.php | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/include/language.php b/include/language.php index f6f266685..d0ecd3a85 100644 --- a/include/language.php +++ b/include/language.php @@ -73,8 +73,35 @@ function get_best_language() { } } - if(! isset($preferred)) + + if(! isset($preferred)) { + + /* + * We could find no perfect match for any of the preferred languages. + * For cases where the preference is fr-fr and we have fr but *not* fr-fr + * run the test again and only look for the language base + * which should provide an interface they can sort of understand + */ + + if(isset($langs) && count($langs)) { + foreach ($langs as $lang => $v) { + if(strlen($lang) === 2) { + /* we have already checked this language */ + continue; + } + /* Check the base */ + $lang = strtolower(substr($lang,0,2)); + if(is_dir("view/$lang")) { + $preferred = $lang; + break; + } + } + } + } + + if(! isset($preferred)) { $preferred = 'unset'; + } $arr = array('langs' => $langs, 'preferred' => $preferred); @@ -86,6 +113,12 @@ function get_best_language() { return ((isset(App::$config['system']['language'])) ? App::$config['system']['language'] : 'en'); } +/* + * push_lang and pop_lang let you temporarily override the default language. + * Often used to email the administrator during a session created in another language. + * The stack is one level deep - so you must pop after every push. + */ + function push_lang($language) { |