Skip to content
Snippets Groups Projects
Commit f16682d1 authored by Jared Hancock's avatar Jared Hancock
Browse files

i18n: Dishonor browser preference if en_US is not enabled

parent b2d2f8a0
Branches
Tags
No related merge requests found
......@@ -236,7 +236,7 @@ class DynamicForm extends VerySimpleModel {
// New translations (?)
if ($vars['trans'] && is_array($vars['trans'])) {
foreach ($vars['trans'] as $lang=>$parts) {
if (!Internationalization::isLanguageInstalled($lang))
if (!Internationalization::isLanguageEnabled($lang))
continue;
foreach ($parts as $T => $content) {
$content = trim($content);
......
......@@ -255,18 +255,28 @@ class Internationalization {
return isset($langs[strtolower($code)]);
}
static function isLanguageEnabled($code) {
$langs = self::getConfiguredSystemLanguages();
return isset($langs[$code]);
}
static function getConfiguredSystemLanguages() {
global $cfg;
static $langs;
if (!$cfg)
return self::availableLanguages();
$pri = $cfg->getPrimaryLanguage();
$langs = array($pri => self::getLanguageInfo($pri));
if (!isset($langs)) {
$pri = $cfg->getPrimaryLanguage();
if ($info = self::getLanguageInfo($pri))
$langs = array($pri => $info);
// Honor sorting preference of ::availableLanguages()
foreach ($cfg->getSecondaryLanguages() as $l) {
$langs[$l] = self::getLanguageInfo($l);
// Honor sorting preference of ::availableLanguages()
foreach ($cfg->getSecondaryLanguages() as $l) {
if ($info = self::getLanguageInfo($l))
$langs[$l] = $info;
}
}
return $langs;
}
......@@ -369,7 +379,7 @@ class Internationalization {
$user = $user ?: $thisstaff ?: $thisclient;
if ($user && method_exists($user, 'getLanguage'))
if ($lang = $user->getLanguage())
if (($lang = $user->getLanguage()) && self::isLanguageEnabled($lang))
return $lang;
// Support the flag buttons for guests
......
......@@ -15,7 +15,7 @@ if($form && $_REQUEST['a']!='add') {
$translations = CustomDataTranslation::allTranslations($trans, 'phrase');
$_keys = array_flip($trans);
foreach ($translations as $t) {
if (!Internationalization::isLanguageInstalled($t->lang))
if (!Internationalization::isLanguageEnabled($t->lang))
continue;
// Create keys of [trans][de_DE][title] for instance
$info['trans'][$t->lang][$_keys[$t->object_hash]]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment