summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorSimon Rettberg2016-06-14 16:10:53 +0200
committerSimon Rettberg2016-06-14 16:10:53 +0200
commit305a3b16c598a98fc7378de3c2ad271e7813de58 (patch)
tree3d9d73dd97f5fd8033862771944872fb4338d336 /modules-available
parentRemove old static sql install (diff)
downloadslx-admin-305a3b16c598a98fc7378de3c2ad271e7813de58.tar.gz
slx-admin-305a3b16c598a98fc7378de3c2ad271e7813de58.tar.xz
slx-admin-305a3b16c598a98fc7378de3c2ad271e7813de58.zip
[translation] Make menu categories a global section instead of a hook in main
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/main/hooks/translation.inc.php17
-rw-r--r--modules-available/translation/lang/de/template-tags.json1
-rw-r--r--modules-available/translation/lang/en/template-tags.json1
-rw-r--r--modules-available/translation/page.inc.php68
-rw-r--r--modules-available/translation/templates/menu-category-list.html23
5 files changed, 92 insertions, 18 deletions
diff --git a/modules-available/main/hooks/translation.inc.php b/modules-available/main/hooks/translation.inc.php
index c831cbfd..03fa5f79 100644
--- a/modules-available/main/hooks/translation.inc.php
+++ b/modules-available/main/hooks/translation.inc.php
@@ -6,7 +6,7 @@ $HANDLER = array();
* List of valid subsections
*/
$HANDLER['subsections'] = array(
- 'categories', 'global-tags'
+ 'global-tags'
);
/*
@@ -15,21 +15,6 @@ $HANDLER['subsections'] = array(
*/
/**
- * Configuration categories
- */
-$HANDLER['grep_categories'] = function($module) {
- $skip = strlen($module->getIdentifier()) + 1;
- $want = array();
- foreach (Module::getAll() as $module) {
- $cat = $module->getCategory();
- if (is_string($cat)) {
- $want[substr($cat, $skip)] = true;
- }
- }
- return $want;
-};
-
-/**
* Global tags.
* This just returns the union of global tags of all languages, as there is no
* way to define a definite set of required global tags.
diff --git a/modules-available/translation/lang/de/template-tags.json b/modules-available/translation/lang/de/template-tags.json
index 3f381751..b8497bd9 100644
--- a/modules-available/translation/lang/de/template-tags.json
+++ b/modules-available/translation/lang/de/template-tags.json
@@ -2,6 +2,7 @@
"lang_createTag": "Tag erstellen",
"lang_global": "Global",
"lang_globalTooltip": "Dieser Tag ist global verf\u00fcgbar und braucht normalerweise nicht explizit f\u00fcr dieses Modul \u00fcbersetzt zu werden",
+ "lang_menuCategories": "Men\u00fckategorien",
"lang_messages": "Benachrichtigungen",
"lang_missing": "Fehlend",
"lang_module": "Modul",
diff --git a/modules-available/translation/lang/en/template-tags.json b/modules-available/translation/lang/en/template-tags.json
index 5aee54c3..ec2a26a3 100644
--- a/modules-available/translation/lang/en/template-tags.json
+++ b/modules-available/translation/lang/en/template-tags.json
@@ -2,6 +2,7 @@
"lang_createTag": "Create Tag",
"lang_global": "Global",
"lang_globalTooltip": "This tag is global; usually there is no need to translate it explicitly for this module",
+ "lang_menuCategories": "Menu categories",
"lang_messages": "Messages",
"lang_missing": "Missing",
"lang_module": "Module",
diff --git a/modules-available/translation/page.inc.php b/modules-available/translation/page.inc.php
index 5b2d24e1..74cf27a8 100644
--- a/modules-available/translation/page.inc.php
+++ b/modules-available/translation/page.inc.php
@@ -42,7 +42,7 @@ class Page_Translation extends Page
public function __construct()
{
- $this->builtInSections = array('template', 'messages', 'module', 'custom');
+ $this->builtInSections = array('template', 'messages', 'module', 'menucategory', 'custom');
}
private function isValidSection($section)
@@ -167,6 +167,13 @@ class Page_Translation extends Page
return;
}
+ // Menu Category
+ if ($this->section === 'menucategory') {
+ $this->ensureValidDestLanguage();
+ $this->showMenuCategoryEdit();
+ return;
+ }
+
// Custom
if ($this->section === 'custom') {
$this->ensureValidDestLanguage();
@@ -174,7 +181,7 @@ class Page_Translation extends Page
return;
}
- $this->redirect();
+ $this->redirect(1);
}
private function showListOfModules()
@@ -212,6 +219,8 @@ class Page_Translation extends Page
$this->showModuleMessages();
// Other/hardcoded strings
$this->showModuleStrings();
+ // Menu categories
+ $this->showModuleMenuCategories();
// Module specific
$this->showModuleCustom();
Render::closeTag('div');
@@ -285,6 +294,23 @@ class Page_Translation extends Page
}
Render::addTemplate('string-list', $data);
}
+
+ private function showModuleMenuCategories()
+ {
+ $moduleTags = $this->loadUsedMenuCategories();
+ $data = array('module' => $this->module->getIdentifier());
+ $data['tagcount'] = count($moduleTags);
+ foreach (Dictionary::getLanguages(true) as $lang) {
+ list($missing, $unused) = $this->getModuleTranslationStatus($lang['cc'], 'menucategory', true, $moduleTags);
+ $data['langs'][] = array(
+ 'cc' => $lang['cc'],
+ 'name' => $lang['name'],
+ 'missing' => $missing,
+ 'unused' => $unused
+ );
+ }
+ Render::addTemplate('menu-category-list', $data);
+ }
private function showModuleCustom()
{
@@ -352,6 +378,17 @@ class Page_Translation extends Page
));
}
+ private function showMenuCategoryEdit()
+ {
+ Render::addTemplate('edit', array(
+ 'destlang' => $this->destLang,
+ 'language' => Dictionary::getLanguageName($this->destLang),
+ 'tags' => $this->loadMenuCategoryEditArray(),
+ 'module' => $this->module->getIdentifier(),
+ 'section' => $this->section
+ ));
+ }
+
private function showCustomEdit()
{
Render::addTemplate('edit', array(
@@ -453,6 +490,23 @@ class Page_Translation extends Page
}
return $tags;
}
+
+ private function loadUsedMenuCategories($module = false)
+ {
+ if ($module === false) {
+ $module = $this->module;
+ }
+ $skip = strlen($module->getIdentifier()) + 1;
+ $match = $module->getIdentifier() . '.';
+ $want = array();
+ foreach (Module::getAll() as $module) {
+ $cat = $module->getCategory();
+ if (is_string($cat) && substr($cat, 0, $skip) === $match) {
+ $want[substr($cat, $skip)] = true;
+ }
+ }
+ return $want;
+ }
private function loadUsedCustomTags($subsection)
{
@@ -657,6 +711,13 @@ class Page_Translation extends Page
$table = $this->buildTranslationTable('module', array_keys($tags), true);
return $table;
}
+
+ private function loadMenuCategoryEditArray()
+ {
+ $tags = $this->loadUsedMenuCategories();
+ $table = $this->buildTranslationTable('categories', array_keys($tags), true);
+ return $table;
+ }
/**
* Get array to pass to edit page with all the message ids.
@@ -865,6 +926,9 @@ class Page_Translation extends Page
if ($this->section === 'module') {
return $prefix . '/module.json';
}
+ if ($this->section === 'menucategory') {
+ return $prefix . '/categories.json';
+ }
// Custom submodule
if ($this->section === 'custom') {
if ($this->customHandler === false || !isset($this->customHandler['subsections'])) {
diff --git a/modules-available/translation/templates/menu-category-list.html b/modules-available/translation/templates/menu-category-list.html
new file mode 100644
index 00000000..4a0df819
--- /dev/null
+++ b/modules-available/translation/templates/menu-category-list.html
@@ -0,0 +1,23 @@
+<div class="col-lg-6">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ {{lang_menuCategories}}
+ </div>
+ <div class="panel-body">
+ <div class="row">
+ <div class="col-sm-6">
+ {{#langs}}
+ <a href="?do=Translation&amp;module={{module}}&amp;section=menucategory&amp;destlang={{cc}}">{{name}} &raquo;</a>
+ <ul>
+ <li>{{lang_missing}}: {{missing}}</li>
+ <li>{{lang_unused}}: {{unused}}</li>
+ </ul>
+ {{/langs}}
+ </div>
+ <div class="col-sm-6">
+ {{lang_tags}}: {{tagcount}}
+ </div>
+ </div>
+ </div>
+ </div>
+</div> \ No newline at end of file