diff options
author | Simon Rettberg | 2016-07-04 15:22:05 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-07-04 15:22:05 +0200 |
commit | 75746e15880c72487864ed62b860052eedc224b6 (patch) | |
tree | d215f39a9303e35bf9d501af36abaa27352d33f8 | |
parent | delete update.inc.php: Not used anymore (diff) | |
download | slx-admin-75746e15880c72487864ed62b860052eedc224b6.tar.gz slx-admin-75746e15880c72487864ed62b860052eedc224b6.tar.xz slx-admin-75746e15880c72487864ed62b860052eedc224b6.zip |
[translation] Improve module list; move baseconfig hook to baseconfig_bwlp
-rw-r--r-- | inc/dictionary.inc.php | 33 | ||||
-rw-r--r-- | modules-available/baseconfig_bwlp/config.json | 3 | ||||
-rw-r--r-- | modules-available/baseconfig_bwlp/hooks/translation.inc.php (renamed from modules-available/baseconfig/hooks/translation.inc.php) | 0 | ||||
-rw-r--r-- | modules-available/translation/page.inc.php | 16 | ||||
-rw-r--r-- | modules-available/translation/templates/module-list.html | 7 |
5 files changed, 51 insertions, 8 deletions
diff --git a/inc/dictionary.inc.php b/inc/dictionary.inc.php index 01651b88..cb23d0b2 100644 --- a/inc/dictionary.inc.php +++ b/inc/dictionary.inc.php @@ -56,10 +56,11 @@ class Dictionary $file = Util::safePath("modules/{$module}/lang/{$lang}/{$path}.json"); if (isset(self::$stringCache[$file])) return self::$stringCache[$file]; - $content = @file_get_contents($file); + if (!file_exists($file)) + return array(); + $content = file_get_contents($file); if ($content === false) { // File does not exist for language $content = '[]'; - error_log("getArray called for non-existent $file"); } $json = json_decode($content, true); if (!is_array($json)) { @@ -156,6 +157,34 @@ class Dictionary return $name; } + /** + * Get an <img> tag for the given language. If there is no flag image, + * fall back to generating a .badge with the CC. + * If long mode is requested, returns the name of the language right next + * to the image, otherwise, it is just added as the title attribute. + * + * @param $caption bool with caption next to <img> + * @param $langCC string Language cc to get flag code for - defaults to current language + * @retrun string html code of img tag for language + */ + public static function getFlagHtml($caption = false, $langCC = false) + { + if ($langCC === false) { + $langCC = LANG; + } + $flag = "lang/$langCC/flag.png"; + $name = htmlspecialchars(self::getLanguageName($langCC)); + if (file_exists($flag)) { + $img = '<img alt="' . $name . '" title="' . $name . '" src="' . $flag . '"> '; + if ($caption) { + $img .= $name; + } + } else { + $img = '<div class="badge" title="' . $name . '">' . $langCC . '</div>'; + } + return $img; + } + } Dictionary::init(); diff --git a/modules-available/baseconfig_bwlp/config.json b/modules-available/baseconfig_bwlp/config.json new file mode 100644 index 00000000..af67a188 --- /dev/null +++ b/modules-available/baseconfig_bwlp/config.json @@ -0,0 +1,3 @@ +{ + "dependencies": ["baseconfig"] +} diff --git a/modules-available/baseconfig/hooks/translation.inc.php b/modules-available/baseconfig_bwlp/hooks/translation.inc.php index 7588fe38..7588fe38 100644 --- a/modules-available/baseconfig/hooks/translation.inc.php +++ b/modules-available/baseconfig_bwlp/hooks/translation.inc.php diff --git a/modules-available/translation/page.inc.php b/modules-available/translation/page.inc.php index 74cf27a8..563ffae0 100644 --- a/modules-available/translation/page.inc.php +++ b/modules-available/translation/page.inc.php @@ -593,20 +593,26 @@ class Page_Translation extends Page private function checkModuleTranslation($module) { - $tags = $this->loadUsedTemplateTags($module); + $templateTags = $this->loadUsedTemplateTags($module); + $messageTags = $this->loadUsedMessageTags($module); + $moduleTags = $this->loadUsedModuleTags($module); $msgs = ''; foreach (Dictionary::getLanguages() as $lang) { - list($missing, $unused) = $this->getModuleTemplateStatus($lang, $tags, $module); + list($m1, $u1) = $this->getModuleTemplateStatus($lang, $templateTags, $module); + list($m2, $u2) = $this->getModuleTranslationStatus($lang, 'messages', true, $messageTags, $module); + list($m3, $u3) = $this->getModuleTranslationStatus($lang, 'module', true, $moduleTags, $module); + $missing = $m1 + $m2 + $m3; + $unused = $u1 + $u2 + $u3; $msg = ""; if ($missing > 0) { - $msg .= " [$missing JSON tag(s) are missing] "; + $msg .= " [$missing missing] "; } if ($unused > 0) { - $msg .= " [$unused JSON tag(s) are not being used] "; + $msg .= " [$unused not being used] "; } if(!empty($msg)) { - $msgs .= "<div><div class='pull-left'><div class='badge'>$lang</div></div> $msg<div class='clearfix'></div></div>"; + $msgs .= '<div><div class="pull-left">' . Dictionary::getFlagHtml(false, $lang) . '</div>' . $msg . '<div class="clearfix"></div></div>'; } } if(empty($msgs)) { diff --git a/modules-available/translation/templates/module-list.html b/modules-available/translation/templates/module-list.html index 81dc741c..026e17e9 100644 --- a/modules-available/translation/templates/module-list.html +++ b/modules-available/translation/templates/module-list.html @@ -11,7 +11,12 @@ <tbody> {{#table}} <tr> - <td><a href="?do=Translation&module={{module}}">{{module}}</a></td> + <td> + {{#depfail}} + <div class="pull-right"><span class="red glyphicon glyphicon-exclamation-sign" title="{{lang_missingDeps}}"></span></div> + {{/depfail}} + <a href="?do=Translation&module={{module}}">{{module}}</a> + </td> <td>{{{status}}}</td> </tr> {{/table}} |