summaryrefslogtreecommitdiffstats
path: root/modules-available/translation
diff options
context:
space:
mode:
authorSimon Rettberg2016-05-04 18:27:28 +0200
committerSimon Rettberg2016-05-04 18:27:28 +0200
commit80424b29e00609bf837119fa810b5afdadf2b4e9 (patch)
treee59c49265aeb219c4137bdf21e71262201345b99 /modules-available/translation
parentWIP (diff)
downloadslx-admin-80424b29e00609bf837119fa810b5afdadf2b4e9.tar.gz
slx-admin-80424b29e00609bf837119fa810b5afdadf2b4e9.tar.xz
slx-admin-80424b29e00609bf837119fa810b5afdadf2b4e9.zip
Work on translations: templates and messages work
Diffstat (limited to 'modules-available/translation')
-rw-r--r--modules-available/translation/lang/de/template-tags.json20
-rw-r--r--modules-available/translation/lang/de/templates/_page.json9
-rw-r--r--modules-available/translation/lang/de/templates/edit.json12
-rw-r--r--modules-available/translation/lang/de/templates/template-list.json5
-rw-r--r--modules-available/translation/lang/en/module.json13
-rw-r--r--modules-available/translation/lang/en/template-tags.json22
-rw-r--r--modules-available/translation/lang/en/templates/_page.json9
-rw-r--r--modules-available/translation/lang/en/templates/edit.json12
-rw-r--r--modules-available/translation/lang/en/templates/template-list.json5
-rw-r--r--modules-available/translation/lang/pt/module.json13
-rw-r--r--modules-available/translation/lang/pt/template-tags.json15
-rw-r--r--modules-available/translation/page.inc.php651
-rw-r--r--modules-available/translation/templates/edit.html137
-rw-r--r--modules-available/translation/templates/module-list.html14
-rw-r--r--modules-available/translation/templates/template-list.html46
15 files changed, 611 insertions, 372 deletions
diff --git a/modules-available/translation/lang/de/template-tags.json b/modules-available/translation/lang/de/template-tags.json
new file mode 100644
index 00000000..60af942b
--- /dev/null
+++ b/modules-available/translation/lang/de/template-tags.json
@@ -0,0 +1,20 @@
+{
+ "lang_adminInfo": "Dies ist eine Liste aller Templates. Die \"Status\"-Spalte zeigt an, wenn f\u00fcr ein Template \u00fcbersetzungen fehlen, oder veraltete Tags definiert sind.",
+ "lang_back": "Z\u00fcruck",
+ "lang_createTag": "TAG schafen",
+ "lang_deleteTAG": "L\u00f6schen",
+ "lang_editConfigModule": "Konfigurationsmodulbezeichnungsphrasen editieren",
+ "lang_editHardcoded": "Hardcoded-Texte bearbeiten",
+ "lang_editMessages": "Nachrichten bearbeiten",
+ "lang_editSettings": "Einstellungstexte bearbeiten",
+ "lang_editTemplates": "Template-Texte bearbeiten",
+ "lang_englishTAG": "Englisch TAG",
+ "lang_germanTAG": "Deutsch TAG",
+ "lang_langAdministration": "Templates",
+ "lang_newTAG": "Neue Tag",
+ "lang_portugueseTAG": "Portugiesisch TAG",
+ "lang_save": "Speichern",
+ "lang_status": "Status",
+ "lang_templateAdminHelp": "Hier k\u00f6nnen Sie die verwendeten Texte und S\u00e4tze \u00fcbersetzen.",
+ "lang_templateHint": "Hinweis: Gelbe Linie zeigt eine \u00dcbersetzung fehlt und roten Linien zeigen ein Tag wird nicht von das Template verwendet."
+} \ No newline at end of file
diff --git a/modules-available/translation/lang/de/templates/_page.json b/modules-available/translation/lang/de/templates/_page.json
deleted file mode 100644
index 639697de..00000000
--- a/modules-available/translation/lang/de/templates/_page.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "lang_adminInfo": "In diesem Abschnitt k\u00f6nnen Sie die JSON-Tags, die \u00fcbersetzten Texte durch die Website verwendet wird, enth\u00e4lt zu \u00e4ndern. Um dies zu tun, w\u00e4hlen Sie eine Vorlage aus, um ihre jeweiligen Tags \u00e4ndern. Alternativ klicken Sie auf den Link unten, um die Nachrichten der Website \u00e4ndern.",
- "lang_editConfigModule": "Konfigurationsmodulbezeichnungsphrasen editieren",
- "lang_editHardcoded": "Hardcoded-Texte bearbeiten",
- "lang_editMessages": "Nachrichten bearbeiten",
- "lang_editSettings": "Einstellungstexte bearbeiten",
- "lang_editTemplates": "Template-Texte bearbeiten",
- "lang_langAdministration": "Sprache Verwaltung"
-} \ No newline at end of file
diff --git a/modules-available/translation/lang/de/templates/edit.json b/modules-available/translation/lang/de/templates/edit.json
deleted file mode 100644
index 671e51d8..00000000
--- a/modules-available/translation/lang/de/templates/edit.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "lang_back": "Z\u00fcruck",
- "lang_createTag": "TAG schafen",
- "lang_deleteTAG": "L\u00f6schen",
- "lang_englishTAG": "Englisch TAG",
- "lang_germanTAG": "Deutsch TAG",
- "lang_newTAG": "Neue Tag",
- "lang_portugueseTAG": "Portugiesisch TAG",
- "lang_save": "Speichern",
- "lang_templateAdminHelp": "Hier k\u00f6nnen Sie die verwendeten Texte und S\u00e4tze \u00fcbersetzen.",
- "lang_templateHint": "Hinweis: Gelbe Linie zeigt eine \u00dcbersetzung fehlt und roten Linien zeigen ein Tag wird nicht von das Template verwendet."
-} \ No newline at end of file
diff --git a/modules-available/translation/lang/de/templates/template-list.json b/modules-available/translation/lang/de/templates/template-list.json
deleted file mode 100644
index 5d6945bc..00000000
--- a/modules-available/translation/lang/de/templates/template-list.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "lang_adminInfo": "Dies ist eine Liste aller Templates. Die \u0022Status\u0022-Spalte zeigt an, wenn f\u00fcr ein Template \u00fcbersetzungen fehlen, oder veraltete Tags definiert sind.",
- "lang_langAdministration": "Templates",
- "lang_status": "Status"
-} \ No newline at end of file
diff --git a/modules-available/translation/lang/en/module.json b/modules-available/translation/lang/en/module.json
index 07bdb07e..bf8920a7 100644
--- a/modules-available/translation/lang/en/module.json
+++ b/modules-available/translation/lang/en/module.json
@@ -1,16 +1,3 @@
{
- "lang_adminInfo": "In this section you can change the JSON tags that contains the translated texts used by the site. To do this, select a template below to modify their respective tags. Alternatively, click the link below to change the messages of the site.",
- "lang_back": "Back",
- "lang_deleteTAG": "Delete",
- "lang_editHardcoded": "Edit hardcoded strings",
- "lang_editMessages": "Edit Messages",
- "lang_editModules": "Edit Module Translations",
- "lang_editSettings": "Edit configuration variables related strings",
- "lang_langAdministration": "Language Administration",
- "lang_module": "Module",
- "lang_save": "Save",
- "lang_status": "Status",
- "lang_templateAdminHelp": "Here you can translate and edit phrases and texts.",
- "lang_templateHint": "Hint: Yellow lines indicate a translation is missing and red lines indicate a tag is not being used by the template.",
"module_name": "Translation"
} \ No newline at end of file
diff --git a/modules-available/translation/lang/en/template-tags.json b/modules-available/translation/lang/en/template-tags.json
new file mode 100644
index 00000000..f9c6b3ba
--- /dev/null
+++ b/modules-available/translation/lang/en/template-tags.json
@@ -0,0 +1,22 @@
+{
+ "lang_adminInfo": "This is a list of all templates. The \"status\"-column tells if there are translations missing, or unused tags are defined.",
+ "lang_back": "Back",
+ "lang_createTag": "Create TAG",
+ "lang_deleteTAG": "Delete",
+ "lang_editConfigModule": "Edit config module strings",
+ "lang_editHardcoded": "Edit hardcoded strings",
+ "lang_editMessages": "Edit Messages",
+ "lang_editModules": "Edit Module Translations",
+ "lang_editSettings": "Edit configuration variables related strings",
+ "lang_editTemplates": "Edit template strings",
+ "lang_englishTAG": "English TAG",
+ "lang_germanTAG": "German TAG",
+ "lang_langAdministration": "Templates",
+ "lang_module": "Module",
+ "lang_newTAG": "New TAG",
+ "lang_portugueseTAG": "Portuguese TAG",
+ "lang_save": "Save",
+ "lang_status": "Status",
+ "lang_templateAdminHelp": "Here you can translate and edit phrases and texts.",
+ "lang_templateHint": "Hint: Yellow lines indicate a translation is missing and red lines indicate a tag is not being used by the template."
+} \ No newline at end of file
diff --git a/modules-available/translation/lang/en/templates/_page.json b/modules-available/translation/lang/en/templates/_page.json
deleted file mode 100644
index 5a48b696..00000000
--- a/modules-available/translation/lang/en/templates/_page.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "lang_adminInfo": "In this section you can change the JSON tags that contains the translated texts used by the site. To do this, select a template below to modify their respective tags. Alternatively, click the link below to change the messages of the site.",
- "lang_editConfigModule": "Edit config module strings",
- "lang_editHardcoded": "Edit hardcoded strings",
- "lang_editMessages": "Edit Messages",
- "lang_editSettings": "Edit configuration variables related strings",
- "lang_editTemplates": "Edit template strings",
- "lang_langAdministration": "Language Administration"
-} \ No newline at end of file
diff --git a/modules-available/translation/lang/en/templates/edit.json b/modules-available/translation/lang/en/templates/edit.json
deleted file mode 100644
index 05c6697a..00000000
--- a/modules-available/translation/lang/en/templates/edit.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "lang_back": "Back",
- "lang_createTag": "Create TAG",
- "lang_deleteTAG": "Delete",
- "lang_englishTAG": "English TAG",
- "lang_germanTAG": "German TAG",
- "lang_newTAG": "New TAG",
- "lang_portugueseTAG": "Portuguese TAG",
- "lang_save": "Save",
- "lang_templateAdminHelp": "Here you can translate and edit phrases and texts.",
- "lang_templateHint": "Hint: Yellow lines indicate a translation is missing and red lines indicate a tag is not being used by the template."
-} \ No newline at end of file
diff --git a/modules-available/translation/lang/en/templates/template-list.json b/modules-available/translation/lang/en/templates/template-list.json
deleted file mode 100644
index e3feb70b..00000000
--- a/modules-available/translation/lang/en/templates/template-list.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "lang_adminInfo": "This is a list of all templates. The \u0022status\u0022-column tells if there are translations missing, or unused tags are defined.",
- "lang_langAdministration": "Templates",
- "lang_status": "Status"
-} \ No newline at end of file
diff --git a/modules-available/translation/lang/pt/module.json b/modules-available/translation/lang/pt/module.json
index 14964c89..47ab1428 100644
--- a/modules-available/translation/lang/pt/module.json
+++ b/modules-available/translation/lang/pt/module.json
@@ -1,16 +1,3 @@
{
- "lang_adminInfo": "Nesta se\u00e7\u00e3o \u00e9 poss\u00edvel alterar as TAGs de JSON que cont\u00e9m os textos traduzidos utilizados no site. Para fazer isto, selecione um template abaixo para modificar suas respectivas TAGs. Alternativamente, clique no link abaixo para alterar as mensagens do site.",
- "lang_back": "Voltar",
- "lang_deleteTAG": "Excluir",
- "lang_editHardcoded": "Editar Textos Hardcoded",
- "lang_editMessages": "Editar Mensagens",
- "lang_editModules": "Editar Tradu\u00e7\u00f5es dos M\u00f3dulos",
- "lang_editSettings": "Editar Textos das Vari\u00e1veis de Configura\u00e7\u00e3o",
- "lang_langAdministration": "Administra\u00e7\u00e3o da L\u00edngua",
- "lang_module": "M\u00f3dulo",
- "lang_save": "Salvar",
- "lang_status": "Status",
- "lang_templateAdminHelp": "Aqui voc\u00ea pode traduzir e editar frases e textos.",
- "lang_templateHint": "Dica: linhas amarelas indicam que uma tradu\u00e7\u00e3o est\u00e1 faltando e linhas vermelhas indicam que uma tag n\u00e3o \u00e9 utilizada pelo template.",
"module_name": "Tradu\u00e7\u00f5es"
} \ No newline at end of file
diff --git a/modules-available/translation/lang/pt/template-tags.json b/modules-available/translation/lang/pt/template-tags.json
new file mode 100644
index 00000000..98d85ee3
--- /dev/null
+++ b/modules-available/translation/lang/pt/template-tags.json
@@ -0,0 +1,15 @@
+{
+ "lang_adminInfo": "Nesta se\u00e7\u00e3o \u00e9 poss\u00edvel alterar as TAGs de JSON que cont\u00e9m os textos traduzidos utilizados no site. Para fazer isto, selecione um template abaixo para modificar suas respectivas TAGs. Alternativamente, clique no link abaixo para alterar as mensagens do site.",
+ "lang_back": "Voltar",
+ "lang_deleteTAG": "Excluir",
+ "lang_editHardcoded": "Editar Textos Hardcoded",
+ "lang_editMessages": "Editar Mensagens",
+ "lang_editModules": "Editar Tradu\u00e7\u00f5es dos M\u00f3dulos",
+ "lang_editSettings": "Editar Textos das Vari\u00e1veis de Configura\u00e7\u00e3o",
+ "lang_langAdministration": "Administra\u00e7\u00e3o da L\u00edngua",
+ "lang_module": "M\u00f3dulo",
+ "lang_save": "Salvar",
+ "lang_status": "Status",
+ "lang_templateAdminHelp": "Aqui voc\u00ea pode traduzir e editar frases e textos.",
+ "lang_templateHint": "Dica: linhas amarelas indicam que uma tradu\u00e7\u00e3o est\u00e1 faltando e linhas vermelhas indicam que uma tag n\u00e3o \u00e9 utilizada pelo template."
+} \ No newline at end of file
diff --git a/modules-available/translation/page.inc.php b/modules-available/translation/page.inc.php
index 3548f727..789500c5 100644
--- a/modules-available/translation/page.inc.php
+++ b/modules-available/translation/page.inc.php
@@ -1,18 +1,64 @@
<?php
+/**
+ * The pages where you can administrate the website translations
+ */
class Page_Translation extends Page
{
/**
- * The pages where you can administrate the website translations
- * @var string|boolean holds the target template
- * @var string|boolean used to choose which page to load
- * @var string|boolean used check if there should be an update
- * @var string|boolean used check if there should be a deletion
- * @var array|boolean holds the tags of the selected template
+ * @var string holds the target template, or subsection for custom section
*/
- private $template = false;
- private $page = false;
+ private $subsection = false;
+
+ /**
+ * @var \Module module being edited, false for module list
+ */
+ private $module = false;
+
+ /**
+ * @var string used to choose which page to load (mode of operation)
+ */
+ private $section = false;
+
+ /**
+ * @var string[] list of sections that are handled directly by this module
+ */
+ private $builtInSections;
+
+ /**
+ * @var array Custom module handler, if any, false otherwise
+ */
+ private $customHandler = false;
+
+ /**
+ * @var type Language being handled (if any in current step)
+ */
+ private $destLang = false;
+
+ /*
+ *
+ */
+
+ public function __construct()
+ {
+ $this->builtInSections = array('template', 'messages', 'custom');
+ }
+
+ private function isValidSection($section)
+ {
+ return in_array($section, $this->builtInSections);
+ }
+
+ private function loadCustomHandler($moduleName)
+ {
+ $path = 'modules/' . $moduleName . '/hooks/translation.inc.php';
+ if (!file_exists($path))
+ return false;
+ $HANDLER = array();
+ require $path;
+ return $HANDLER;
+ }
protected function doPreprocess()
{
@@ -22,26 +68,85 @@ class Page_Translation extends Page
Message::addError('no-permission');
Util::redirect('?do=Main');
}
+
+ // Set up variables
+ // Module to be edited
+ $moduleName = Request::any('module', false, 'string');
+ if ($moduleName !== false) {
+ $this->module = Module::get($moduleName, true);
+ if ($this->module === false) {
+ Message::addError('main.no-such-module', $moduleName);
+ Util::redirect('?do=Translation');
+ } elseif ($this->module->hasMissingDependencies()) {
+ Message::addError('main.module-missing-deps', $moduleName);
+ Util::redirect('?do=Translation');
+ }
+ $this->customHandler = $this->loadCustomHandler($moduleName);
+ }
+ // Section
+ $sectionName = Request::any('section', false, 'string');
+ if ($sectionName !== false) {
+ if (!$this->isValidSection($sectionName)) {
+ Message::addError('invalid-section', $sectionName);
+ if ($moduleName !== false) {
+ Util::redirect('?do=Translation&module=' . $moduleName);
+ }
+ Util::redirect('?do=Translation');
+ }
+ }
+ // Section
+ $this->section = $sectionName;
+ // Subsection (being checked when used)
+ $this->subsection = Request::any('subsection', false, 'string');
+ // LANG (verify if needed)
+ $this->destLang = Request::any('destlang', false, 'string');
if (Request::post('update')) {
$this->updateJson();
Util::redirect('?do=Translation');
}
- if (Request::post('delete')) {
- $this->deleteTag(Request::post('path'), Request::post('delete'));
- Util::redirect('?do=Translation'); // TODO: Ajax post for delete so we stay on the page
+ }
+
+ private function ensureValidDestLanguage()
+ {
+ if (!in_array($this->destLang, Dictionary::getLanguages())) {
+ Message::addError('i18n-invalid-lang', $this->destLang);
+ Util::redirect('?do=Translation');
}
-
- $this->template = Request::get('template');
- $this->page = Request::get('page');
}
protected function doRender()
{
$langs = Dictionary::getLanguages(true);
+
+ // Overview (list of modules)
+ if ($this->module === false) {
+ $this->showModuleList();
+ return;
+ }
+
+ // One module - overview
+ if ($this->section === false) {
+ $this->showModule();
+ return;
+ }
+
+ // Edit template string
+ if ($this->section === 'template') {
+ $this->ensureValidDestLanguage();
+ $this->showTemplateEdit();
+ return;
+ }
+
+ // Messugiz
+ if ($this->section === 'messages') {
+ $this->ensureValidDestLanguage();
+ $this->showMessagesEdit();
+ return;
+ }
//load the page accordingly to the link
- switch ($this->page) {
+ switch ($this->section) {
case 'messages':
//renders the message edit page
Render::addTemplate('edit', array(
@@ -79,56 +184,85 @@ class Page_Translation extends Page
'tags' => $this->buildTranslationTable('config-module')
));
break;
- case 'template':
- $this->template = Util::safePath($this->template);
- if ($this->template === false) {
- Message::addError('invalid-path');
- Util::redirect('?do=Translation');
- }
- //renders the tag edition page
- Render::addTemplate('edit', array(
- 'path' => 'modules/' . $this->template,
- 'langs' => $langs,
- 'tags' => $this->loadTemplateEditArray($this->template)
- ));
- break;
- case 'templates':
- //renders the template selection page
- Render::addTemplate('template-list', array(
- 'table' => $this->loadTemplatesList(),
- ));
- break;
- case 'modules':
- Render::addTemplate('module-list', array(
- 'table' => $this->loadModuleTable()
- ));
- break;
default:
//renders main page with selection of what part to edit
Render::addTemplate('_page');
}
}
- private function loadModuleTable(){
+ private function showModuleList()
+ {
$table = array();
- $modules = $this->loadModuleList();
+ $modules = Module::getAll();
foreach ($modules as $module) {
$msgs = $this->checkModuleTranslation($module);
$table[] = array(
- 'module' => $module,
+ 'module' => $module->getIdentifier(),
+ 'depfail' => $module->hasMissingDependencies(),
'status' => $msgs
);
}
sort($table);
- return $table;
+ Render::addTemplate('module-list', array(
+ 'table' => $table
+ ));
+ }
+
+ private function showModule()
+ {
+ $templateTags = $this->loadModuleTemplateTags();
+ $data = array(
+ 'module' => $this->module->getIdentifier(),
+ 'moduleName' => $this->module->getDisplayName()
+ );
+ $list = array();
+ $data['tagcount'] = 0;
+ foreach ($templateTags as $templates) {
+ $list = array_merge($list, $templates);
+ $data['tagcount']++;
+ }
+ foreach (Dictionary::getLanguages(true) as $lang) {
+ list($missing, $unused) = $this->getModuleTemplateStatus($lang['cc'], $templateTags);
+ $data['langs'][] = array(
+ 'cc' => $lang['cc'],
+ 'name' => $lang['name'],
+ 'missing' => $missing,
+ 'unused' => $unused
+ );
+ }
+ $data['templates'] = array();
+ foreach (array_unique($list) as $template) {
+ $data['templates'][] = array('template' => $template);
+ }
+ Render::addTemplate('template-list', $data);
+ }
+
+ private function showTemplateEdit()
+ {
+ Render::addTemplate('edit', array(
+ 'destlang' => $this->destLang,
+ 'tags' => $this->loadTemplateEditArray(),
+ 'module' => $this->module->getIdentifier(),
+ 'section' => $this->section
+ ));
+ }
+
+ private function showMessagesEdit()
+ {
+ Render::addTemplate('edit', array(
+ 'destlang' => $this->destLang,
+ 'tags' => $this->loadMessagesEditArray(),
+ 'module' => $this->module->getIdentifier(),
+ 'section' => $this->section
+ ));
}
private function loadModuleEdit(){
$table = array();
- $tags = array_flip($this->loadModuleTags($this->module));
+ $tags = array_flip($this->loadModuleTemplateTags($this->module));
foreach ($this->langs as $lang) {
$tags = array_merge($tags, Dictionary::getArray($this->module,$lang['cc']));
}
@@ -142,7 +276,7 @@ class Page_Translation extends Page
'placeholder' => 'TAG - ' . $lang['name'],
'translation' => $translations[$tag]
);
- if(!in_array($tag, $this->loadModuleTags($this->module)))
+ if(!in_array($tag, $this->loadModuleTemplateTags($this->module)))
$class = 'danger';
else if(!$translations[$tag])
$class = 'warning';
@@ -157,58 +291,105 @@ class Page_Translation extends Page
return $table;
}
- private function loadModuleList(){
- // Return an array with the modules and the tags data
- $list = array();
- $list = array_diff(scandir('modules/'), array('..', '.'));
- return $list;
+ /**
+ * Get all tags used by templates of the given module.
+ * @param \Module $module module in question, false to use the one being edited
+ * @return array inde is tag, valie is array of templates using that tag
+ */
+ private function loadModuleTemplateTags($module = false)
+ {
+ if ($module === false) {
+ $module = $this->module;
+ }
+ $tags = array();
+ $path = 'modules/' . $module->getIdentifier() . '/templates';
+ if (is_dir($path)) {
+ // Return an array with the module language tags
+ $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
+ foreach ($objects as $name => $object) {
+ if (substr($name, -5) === '.html' && is_file($name)) {
+ $relTemplateName = substr($name, strlen($path), -5);
+ foreach ($this->getTagsFromTemplate($name) as $tag) {
+ $tags[$tag][] = $relTemplateName;
+ }
+ }
+ }
+ }
+ return $tags;
}
+
+ private function getTagsFromTemplate($templateFile)
+ {
+ //checks if the template is valid
+ if (!file_exists($templateFile)) {
+ Message::addError('invalid-template', $templateFile);
+ return false;
+ }
- private function loadModuleTags($module){
- // Return an array with the module language tags
- $path = "modules/" . $module . "templates/";
- $files = array_diff(scandir($path), array('..', '.'));
- $tags = array();
- foreach ($files as $file) {
- $content = file_get_contents($path . $file);
- preg_match_all('/{{(lang_.*?)}}/s', $content, $matches);
- if (isset($matches[1]) && is_array($matches[1])){
- $tags = array_merge($tags,array_unique($matches[1]));
+ //finds every mustache tag within the html template
+ $htmlTemplate = file_get_contents($templateFile);
+ preg_match_all('/{{(lang_.*?)}}/s', $htmlTemplate, $matches);
+ if (!isset($matches[1]) || !is_array($matches[1]))
+ return array();
+ return array_unique($matches[1]);
+ }
+
+ /**
+ * Get missing and unused counters for given module's templates.
+ *
+ * @param type $lang lang to use
+ * @param type $tags
+ * @param type $module
+ * @return array list(missingCount, unusedCount)
+ */
+ private function getModuleTemplateStatus($lang, $tags = false, $module = false)
+ {
+ if ($module === false) {
+ $module = $this->module;
+ }
+ if ($tags === false) {
+ $tags = $this->loadModuleTemplateTags($module);
+ }
+ $globalTranslation = Dictionary::getArray('main', 'global-template-tags', $lang);
+ $translation = array_unique(array_merge(Dictionary::getArray($module->getIdentifier(), 'template-tags', $lang), $globalTranslation));
+ $matches = 0;
+ $unused = 0;
+ $expected = count($tags);
+ foreach ($translation as $key => $value) {
+ if(!isset($tags[$key])) {
+ if (!in_array($key, $globalTranslation)) {
+ $unused++;
+ }
+ } else {
+ $matches++;
}
+
}
- return array_unique($tags);
+ $missing = $expected - $matches;
+ return array($missing, $unused);
}
- private function checkModuleTranslation($module){
- $tags = $this->loadModuleTags($module);
- $translation = array();
+ private function checkModuleTranslation($module)
+ {
+ $tags = $this->loadModuleTemplateTags($module);
$msgs = '';
- foreach ($this->langs as $key => $lang) {
- $translation = Dictionary::getArray($module,$lang['cc']);
- $matches = 0;
- $unused = 0;
- $expected = count($tags);
- foreach ($translation as $key => $value) {
- if(!in_array($key, $tags))
- $unused ++;
- else if(!empty($value))
- $matches ++;
+ foreach (Dictionary::getLanguages() as $lang) {
+ list($missing, $unused) = $this->getModuleTemplateStatus($lang, $tags, $module);
- }
-
- $diff = $expected - $matches;
$msg = "";
- if ($diff > 0)
- $msg .= $diff . " JSON tag(s) are missing";
- if ($diff > 0 && $unused > 0)
- $msg .= "<br>";
- if ($unused > 0)
- $msg .= $unused . " JSON tag(s) are not being used";
- if(!empty($msg))
- $msgs .= "<div><span class='badge'>{$lang['name']}:</span> $msg</div>";
- }
- if(empty($msgs))
+ if ($missing > 0) {
+ $msg .= " [$missing JSON tag(s) are missing] ";
+ }
+ if ($unused > 0) {
+ $msg .= " [$unused JSON tag(s) are not being used] ";
+ }
+ if(!empty($msg)) {
+ $msgs .= "<div><div class='pull-left'><div class='badge'>$lang</div></div> $msg<div class='clearfix'></div></div>";
+ }
+ }
+ if(empty($msgs)) {
$msgs = 'OK';
+ }
return $msgs;
}
/**
@@ -271,13 +452,13 @@ class Page_Translation extends Page
* Finds and returns all PHP files of slxadmin
* @return array of all php files
*/
- private function listPhp()
+ private function getModulePhpFiles()
{
$php = array();
- $dir = '.';
+ $dir = 'modules/' . $this->module->getIdentifier();
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
foreach ($objects as $name => $object) {
- if (substr($name, -4) === '.php') {
+ if (substr($name, -4) === '.php' && is_file($name)) {
$php[] = $name;
}
}
@@ -330,16 +511,83 @@ class Page_Translation extends Page
}
/**
- * Get array to pass to edit page with all the tags and translations for the given template
+ * Get array to pass to edit page with all the tags and translations.
+ *
* @param string $path the template's path
- * @return array the information about the JSON tags
+ * @return array structure to pass to the tags list in the edit template
*/
- private function loadTemplateEditArray($path)
+ private function loadTemplateEditArray()
{
- $tags = $this->loadTemplateTags($path);
+ $tags = $this->loadModuleTemplateTags();
if ($tags === false)
return false;
- return $this->buildTranslationTable("modules/" . $path, $tags);
+ $table = $this->buildTranslationTable('template-tags', array_keys($tags), true);
+ $global = Dictionary::getArray($this->module->getIdentifier(), 'global-template-tags', $this->destLang);
+ foreach ($table as &$entry) {
+ if (empty($entry['translation']) && isset($global[$entry['tag']])) {
+ $entry['placeholder'] = $global[$entry['tag']];
+ }
+ if (!isset($tags[$entry['tag']]))
+ continue;
+ $entry['notes'] = implode('<br>', $tags[$entry['tag']]);
+ }
+ return $table;
+ }
+
+ /**
+ * Get array to pass to edit page with all the message ids.
+ *
+ * @param string $path the template's path
+ * @return array structure to pass to the tags list in the edit template
+ */
+ private function loadMessagesEditArray()
+ {
+ // TODO: Scan for uses in other modules, handle module.id syntax
+ $tags = $this->loadTagsFromPhp('/Message\s*::\s*add\w+\s*\(\s*[\'"]([^\'"]*)[\'"]\s*(\)|\,.*)/i');
+ $table = $this->buildTranslationTable('messages', array_keys($tags), true);
+ foreach ($table as &$entry) {
+ if (isset($tags[$entry['tag']]) && is_string($tags[$entry['tag']])) {
+ $entry['notes'] = 'Params: ' . $this->countMessageParams($tags[$entry['tag']]);
+ }
+ }
+ return $table;
+ }
+
+ private function countMessageParams($str)
+ {
+ error_log($str);
+ $quote = false;
+ $escape = false;
+ $count = 0;
+ $len = strlen($str);
+ $depth = 0;
+ for ($i = 0; $i < $len; ++$i) {
+ $char = $str{$i};
+ if ($escape) {
+ $escape = false;
+ continue;
+ }
+ if ($quote === false) {
+ if ($char === ',') {
+ if ($depth === 0) {
+ $count++;
+ }
+ } elseif ($char === '"' || $char === "'") {
+ $quote = $char;
+ } elseif ($char === '{' || $char === '(' || $char === '[') {
+ $depth++;
+ } elseif ($char === '}' || $char === ')' || $char === ']') {
+ $depth--;
+ }
+ } else {
+ if ($char === $quote) {
+ $quote = false;
+ } elseif ($char === '\\') {
+ $escape = true;
+ }
+ }
+ }
+ return $count;
}
/**
@@ -365,23 +613,12 @@ class Page_Translation extends Page
}
/**
- * Load array of tags and translations of all messages
- * @return array the information about the JSON tags
- */
- private function loadMessageEditArray()
- {
- $tags = $this->loadTagsFromPhp('/Message\s*::\s*add\w+\s*\(\s*[\'"](.*?)[\'"]\s*[\)\,]/i');
- if ($tags === false)
- return false;
- return $this->buildTranslationTable('messages', $tags);
- }
-
- /**
* Load array of tags and translations of all strings found in the php files.
* @return array the information about the JSON tags
*/
private function loadHardcodedStringEditArray()
{
+ // TODO: Return changed
$tags = $this->loadTagsFromPhp('/Dictionary\s*::\s*translate\s*\(\s*[\'"]([^\'"]*?)[\'"]\s*\)/i');
if ($tags === false)
return false;
@@ -397,65 +634,70 @@ class Page_Translation extends Page
private function loadTagsFromPhp($regexp)
{
// Get all php files, so we can find all strings that need to be translated
- $php = $this->listPhp();
+ $php = $this->getModulePhpFiles();
$tags = array();
// Now find all tags in all php files. Only works for literal usage, not something like $foo = 'bar'; Dictionary::translate($foo);
foreach ($php as $file) {
$content = @file_get_contents($file);
- if ($content === false || preg_match_all($regexp, $content, $out) < 1)
+ if ($content === false || preg_match_all($regexp, $content, $out, PREG_SET_ORDER) < 1)
continue;
- foreach ($out[1] as $id) {
- $tags[$id] = true;
+ foreach ($out as $set) {
+ $tags[$set[1]] = isset($set[2]) ? $set[2] : true;
}
}
- return array_keys($tags);
+ return $tags;
}
- private function buildTranslationTable($path, $requiredTags = false)
+ private function buildTranslationTable($file, $requiredTags = false, $findAlreadyTranslated = false)
{
- // All languages
- $langArray = Dictionary::getLanguages();
-
$tags = array();
if ($requiredTags !== false) {
foreach ($requiredTags as $tagName) {
$tags[$tagName] = array('tag' => $tagName);
- foreach ($langArray as $lang) {
- $tags[$tagName]['langs'][$lang]['lang'] = $lang;
- $tags[$tagName]['missing'] = count($langArray);
- }
}
}
- // Finds every JSON tag within the JSON language files
- foreach ($langArray as $lang) {
- $jsonTags = Dictionary::getArray($path, $lang, true);
- if (!is_array($jsonTags))
- continue;
+ // Finds every tag within the JSON language file
+ $jsonTags = Dictionary::getArray($this->module->getIdentifier(), $file, $this->destLang);
+ if (is_array($jsonTags)) {
foreach ($jsonTags as $tag => $translation) {
- $tags[$tag]['langs'][$lang]['translation'] = $translation;
- $tags[$tag]['langs'][$lang]['lang'] = $lang;
- if (strpos($translation, "\n") !== false)
- $tags[$tag]['langs'][$lang]['big'] = true;
+ $tags[$tag]['translation'] = $translation;
+ if (strpos($translation, "\n") !== false) {
+ $tags[$tag]['big'] = true;
+ }
$tags[$tag]['tag'] = $tag;
- if (!isset($tags[$tag]['missing']))
- $tags[$tag]['missing'] = 0;
- if (!empty($translation))
- $tags[$tag]['missing'] --;
}
}
- // Fill the blanks
- foreach ($langArray as $lang) {
- foreach (array_keys($tags) as $tagName) {
- if (!isset($tags[$tagName]['langs'][$lang]))
- $tags[$tagName]['langs'][$lang]['lang'] = $lang;
+ if ($findAlreadyTranslated) {
+ $srcLangs = array_merge(array(LANG), array('en'), Dictionary::getLanguages());
+ $srcLangs = array_unique($srcLangs);
+ $key = array_search($this->destLang, $srcLangs);
+ if ($key !== false) {
+ unset($srcLangs[$key]);
+ }
+ foreach ($srcLangs as $lang) {
+ $otherLang = Dictionary::getArray($this->module->getIdentifier(), $file, $lang);
+ if (!is_array($otherLang))
+ continue;
+ $missing = false;
+ foreach (array_keys($tags) as $tag) {
+ if (isset($tags[$tag]['samplelang']))
+ continue;
+ if (!isset($otherLang[$tag])) {
+ $missing = true;
+ } else {
+ $tags[$tag]['samplelang'] = $lang;
+ $tags[$tag]['sampletext'] = $otherLang[$tag];
+ }
+ }
+ if (!$missing)
+ break;
}
}
- // Finally remove $lang from the keys so mustache will iterate over them via {{#..}}
+ $tagid = 0;
foreach ($tags as &$tag) {
- $tag['langs'] = array_values($tag['langs']);
- if ($requiredTags !== false)
- $tag['class'] = $this->getTagColor($tag['missing']);
+ $tag['tagid'] = $tagid++;
}
+ // Finally remove $lang from the keys so mustache will iterate over them via {{#..}}
return array_values($tags);
}
@@ -477,91 +719,96 @@ class Page_Translation extends Page
//if it's ok don't change the class
return '';
}
+
+ private function getJsonFile()
+ {
+ $prefix = 'modules/' . $this->module->getIdentifier() . '/lang/' . $this->destLang;
+ // File
+ if ($this->section === 'messages') {
+ return $prefix . '/messages.json';
+ }
+ if ($this->section === 'template') {
+ return $prefix . '/template-tags.json';
+ }
+ // Custom submodule
+ if ($this->section === 'custom') {
+ if ($this->customHandler === false || !isset($this->customHandler['subsections'])) {
+ Message::addError('no-custom-handlers');
+ Util::redirect('?do=Translation');
+ }
+ if (!in_array($this->subsection, $this->customHandler['subsections'], true)) {
+ Message::addError('invalid-custom-handler', $this->subsection);
+ Util::redirect('?do=Translation');
+ }
+ return $prefix . '/' . $this->subsection;
+ }
+ Message::addError('invalid-section', $this->section);
+ Util::redirect('?do=Translation');
+ }
/**
* Updates a JSON file with it's new tags or/and tags values
*/
private function updateJson()
{
- $langArray = Dictionary::getLanguages();
- foreach ($langArray as $lang) {
- $json[$lang] = array();
+ $this->ensureValidDestLanguage();
+ if ($this->module === false) {
+ Message::addError('main.no-module-given');
+ Util::redirect('?do=Translation');
}
+ $file = $this->getJsonFile();
+
+ $data = array();
//find the tag requests to change the file
foreach ($_POST as $key => $value) {
- $str = explode('#', $key, 3);
- if (count($str) !== 3 || $str[0] !== 'lang')
- continue;
- $lang = $str[1];
- $tag = trim($str[2]);
- if (!isset($json[$lang])) {
- Message::addWarning('i18n-invalid-lang', $lang);
+ $str = explode('#!#', $key, 2);
+ if (count($str) !== 2)
continue;
- }
- if (empty($tag)) {
- Message::addWarning('i18n-empty-tag');
- continue;
- }
- $value = trim($value);
- if ($tag !== 'newtag') {
+ if ($str[0] === 'lang') {
+ $tag = trim($str[1]);
+ if (empty($tag)) {
+ Message::addWarning('i18n-empty-tag');
+ continue;
+ }
if (empty($value)) {
- unset($json[$lang][$tag]);
+ unset($data[$tag]);
} else {
- $json[$lang][$tag] = $value;
+ $data[$tag] = $value;
}
- } else {
- if (!empty($value)) // TODO: Error message if new tag's name collides with existing
- $json[$lang][$_REQUEST['newtag']] = $value;
}
}
-
- // JSON_PRETTY_PRINT is only available starting with php 5.4.0.... Use upgradephp's json_encode
- require_once('inc/up_json_encode.php');
+
+ $translation = Request::post('new-text', array(), 'array');
+ foreach (Request::post('new-id', array(), 'array') as $k => $tag) {
+ if (empty($translation[$k]))
+ continue;
+ $data[(string)$tag] = (string)$translation[$k];
+ }
//saves the new values on the file
- foreach ($json as $key => $array) {
- $path = Util::safePath('lang/' . $key . '/' . Request::post('path') . '.json');
- if ($path === false) {
- Message::addError('invalid-path');
- Util::redirect('?do=Translation');
+ $path = dirname($file);
+ if (!is_dir($path)) {
+ mkdir($path, 0755, true);
+ }
+
+ if (empty($data)) {
+ if (file_exists($file)) {
+ unlink($file);
}
- @mkdir(dirname($path), 0755, true);
- ksort($array); // Sort by key, so the diff on the output is cleaner
- $json = up_json_encode($array, JSON_PRETTY_PRINT); // Also for better diffability of the json files, we pretty print
+ } else {
+ // JSON_PRETTY_PRINT is only available starting with php 5.4.0.... Use upgradephp's json_encode
+ require_once('inc/up_json_encode.php');
+ ksort($data); // Sort by key, so the diff on the output is cleaner
+ $json = up_json_encode($data, JSON_PRETTY_PRINT); // Also for better diffability of the json files, we pretty print
//exits the function in case the action was unsuccessful
- if (@file_put_contents($path, $json) === false) {
+ if (file_put_contents($file, $json) === false) {
Message::addError('invalid-template');
return;
}
}
- Message::addSuccess('updated-tags');
- }
- /**
- * Delete a specific JSON tag from a JSON files
- * @var string the JSON's file path
- * @var the JSON tag to be deleted
- * @return boolean if the action was not successful
- */
- private function deleteTag($path, $tag)
- {
- // JSON_PRETTY_PRINT is only available starting with php 5.4.0.... Use upgradephp's json_encode
- require_once('inc/up_json_encode.php');
-
- //delete the tag from every language file
- $langArray = Dictionary::getLanguages();
- foreach ($langArray as $lang) {
- $json = Dictionary::getArray($path, $lang);
- unset($json[$tag]);
- $result = file_put_contents('lang/' . $lang . '/' . $path . '.json', up_json_encode($json, JSON_PRETTY_PRINT));
- //add warning and exit in case the action was unsuccessful
- if ($result === false) {
- Message::addWarning('unsuccessful-action');
- return false;
- }
- }
- Message::addSuccess('deleted-tag');
+ Message::addSuccess('updated-tags');
}
/**
diff --git a/modules-available/translation/templates/edit.html b/modules-available/translation/templates/edit.html
index dc01deb6..2cc0e599 100644
--- a/modules-available/translation/templates/edit.html
+++ b/modules-available/translation/templates/edit.html
@@ -1,67 +1,92 @@
-<div class="container">
- <div class="panel panel-default">
- <div class="panel-heading">
- {{path}}
+<div class="panel panel-default">
+ <div class="panel-heading">
+ {{module}} / {{section}}
+ </div>
+ <div class="panel-body">
+ <p>{{lang_templateAdminHelp}}</p>
+ <div class="alert alert-info">
+ {{lang_templateHint}}
</div>
- <div class="panel-body">
- <p>{{lang_templateAdminHelp}}</p>
- <div class="alert alert-info">
- {{lang_templateHint}}
+ <form action="?do=Translation" method="post" class="slx-visible-rows">
+ <input type="hidden" name="module" value="{{module}}">
+ <input type="hidden" name="destlang" value="{{destlang}}">
+ <input type="hidden" name="section" value="{{section}}">
+ <input type="hidden" name="subsection" value="{{subsection}}">
+ <input type="hidden" name="token" value="{{token}}">
+ <a class="btn btn-primary" href='?do=Translation' >{{lang_back}}</a>
+ <button class="btn btn-primary" type="button" onclick="addTag()" >{{lang_createTag}}</button>
+ <button type="submit" class="btn btn-primary" name="update" value="true">{{lang_save}}</button>
+ <div class="row">
+ <div class="col-xs-4 col-sm-3">{{lang_tag}}</div>
+ <div class="col-xs-6 col-sm-4">{{lang_translation}}</div>
+ <div class="hidden-xs col-sm-4">{{lang_sample}}</div>
+ <div class="col-xs-2 col-sm-1">!</div>
</div>
- <form action="?do=Translation" method="post">
- <input type="hidden" name="path" value="{{path}}">
- <input type="hidden" name="token" value="{{token}}">
- <a class="btn btn-primary" href='?do=Translation' >{{lang_back}}</a>
- <button class="btn btn-primary" type="button" onclick="addTag()" >{{lang_createTag}}</button>
- <button type="submit" class="btn btn-primary" name="update" value="true">{{lang_save}}</button>
- <table class="table table-hover">
- <thead>
- <tr>
- <th>Mustache Tag</th>
- {{#langs}}
- <th>{{name}}</th>
- {{/langs}}
- <th></th>
- </tr>
- </thead>
- <tbody>
- {{#tags}}
- <tr class="{{class}}" id="{{tag}}">
- <td>{{tag}}</td>
- {{#langs}}
- <td>
- {{^big}}
- <input type="text" class="form-control switchable" value="{{translation}}" ondblclick="mb(this)" name="lang#{{lang}}#{{tag}}">
- {{/big}}
- {{#big}}
- <textarea rows="3" class="form-control" name="lang#{{lang}}#{{tag}}">{{translation}}</textarea>
- {{/big}}
- </td>
- {{/langs}}
- <td>
- <button type="submit" class="btn btn-danger btn-xs" name="delete" value="{{tag}}"><span class="glyphicon glyphicon-remove"></span> {{lang_deleteTAG}}</button>
- </td>
- </tr>
- {{/tags}}
- <tr id="newTag">
- </tr>
- </tbody>
- </table>
- <a class="btn btn-primary" href='?do=Translation' >{{lang_back}}</a>
- <button class="btn btn-primary" type="button" onclick="addTag()" >{{lang_createTag}}</button>
- <button type="submit" class="btn btn-primary" name="update" value="true">{{lang_save}}</button>
- </form>
- </div>
+ {{#tags}}
+ <div class="row {{class}}">
+ <div class="col-xs-4 col-sm-3">
+ {{tag}}
+ <div class="slx-notebox">{{{notes}}}</div>
+ </div>
+ <div class="col-xs-6 col-sm-4" id="tagid-{{tagid}}">
+ {{^big}}
+ <input type="text" class="form-control switchable" value="{{translation}}" ondblclick="slxMb(this)" name="lang#!#{{tag}}" placeholder="{{placeholder}}">
+ {{/big}}
+ {{#big}}
+ <textarea rows="3" class="form-control" name="lang#!#{{tag}}" placeholder="{{placeholder}}">{{translation}}</textarea>
+ {{/big}}
+ </div>
+ <div class="hidden-xs col-sm-4">
+ <div class="slx-textpreview"><div>
+ <div class="badge">{{samplelang}}</div>
+ {{sampletext}}
+ </div></div>
+ </div>
+ <div class="col-xs-2 col-sm-1">
+ <button type="button" class="btn btn-danger btn-xs" onclick="slxDelTag({{tagid}})"><span class="glyphicon glyphicon-remove"></span> {{lang_deleteTAG}}</button>
+ </div>
+ </div>
+ {{/tags}}
+ <div id="newTag"></div>
+ <a class="btn btn-primary" href='?do=Translation' >{{lang_back}}</a>
+ <button class="btn btn-primary" type="button" onclick="slxAddTag()" >{{lang_createTag}}</button>
+ <button type="submit" class="btn btn-primary" name="update" value="true">{{lang_save}}</button>
+ </form>
</div>
</div>
<script type="text/javascript">
- function addTag()
+ var slxNewTagCounter = 0;
+ function slxAddTag()
+ {
+ $('#newTag').before(
+ '<div class="row" id="new-delete-' + slxNewTagCounter + '">' +
+ ' <div class="col-xs-4 col-sm-3">' +
+ ' <input type="text" name="new-id[' + slxNewTagCounter + ']" class="form-control">' +
+ ' </div>' +
+ ' <div class="col-xs-6 col-sm-4">' +
+ ' <input type="text" class="form-control" name="new-text[' + slxNewTagCounter + ']">' +
+ ' </div>' +
+ ' <div class="hidden-xs col-sm-4">' +
+ ' </div>' +
+ ' <div class="col-xs-2 col-sm-1">' +
+ ' <button type="button" class="btn btn-danger btn-xs" onclick="slxDelNew(' + slxNewTagCounter + ')"><span class="glyphicon glyphicon-remove"></span> {{lang_deleteTAG}}</button>' +
+ ' </div>' +
+ '</div>'
+ );
+ slxNewTagCounter++;
+ }
+
+ function slxDelNew(id)
+ {
+ $('#new-delete-' + id).remove();
+ }
+
+ function slxDelTag(id)
{
- var target = document.getElementById('newTag');
- target.innerHTML = "<td> <input type='text' class='form-control' placeholder='{{lang_newTAG}}' name='newtag'> </td> <td style='width:250px;text-align:center;'> <input type='text' class='form-control' placeholder='{{lang_germanTAG}}' name='lang#de#newtag'> </td> <td style='width:250px;text-align:center;'> <input type='text' class='form-control' placeholder='{{lang_englishTAG}}' name='lang#en#newtag'> </td> <td style='width:250px;text-align:center;'> <input type='text' class='form-control' placeholder='{{lang_portugueseTAG}}' name='lang#pt#newtag'> </td><td></td>";
+ $('#tagid-' + id).text('-');
}
- function mb(el)
+ function slxMb(el)
{
var old = $(el);
var ta = $('<textarea name="' + el.name + '" class="form-control" rows="3"></textarea>');
diff --git a/modules-available/translation/templates/module-list.html b/modules-available/translation/templates/module-list.html
index 037a21bc..589fa0d4 100644
--- a/modules-available/translation/templates/module-list.html
+++ b/modules-available/translation/templates/module-list.html
@@ -7,26 +7,20 @@
</div>
</div>
<div class="panel panel-default">
- <table class="table table-hover">
+ <table class="table">
<thead>
<tr>
- <th width="350">{{lang_module}}</th>
+ <th>{{lang_module}}</th>
<th>{{lang_status}}</th>
<tr>
</thead>
<tbody>
{{#table}}
- <tr onclick="goTo('{{module}}');">
- <td>{{module}}</td>
+ <tr>
+ <td><a href="?do=Translation&amp;module={{module}}">{{module}}</a></td>
<td>{{{status}}}</td>
</tr>
{{/table}}
</tbody>
</table>
</div>
-
-<script>
-function goTo(link){
- window.location.href = "?do=Translation&page=module&module=" + link;
-}
-</script>
diff --git a/modules-available/translation/templates/template-list.html b/modules-available/translation/templates/template-list.html
index 881fc5af..59d0f7cf 100644
--- a/modules-available/translation/templates/template-list.html
+++ b/modules-available/translation/templates/template-list.html
@@ -1,32 +1,26 @@
+<h1>{{moduleName}} ({{module}})</h1>
<div class="panel panel-default">
<div class="panel-heading">
- {{lang_langAdministration}}
+ {{lang_templates}}
</div>
<div class="panel-body">
- <p>{{lang_adminInfo}}</p>
+ <div class="row">
+ <div class="col-sm-6">
+ {{#langs}}
+ <a href="?do=Translation&amp;module={{module}}&amp;section=template&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}}
+ <ul>
+ {{#templates}}
+ <li>{{template}}</li>
+ {{/templates}}
+ </ul>
+ </div>
</div>
</div>
-<div class="panel panel-default">
- <table class="table table-hover">
- <thead>
- <tr>
- <th>Template</th>
- <th>{{lang_status}}</th>
- <tr>
- </thead>
- <tbody>
- {{#table}}
- <tr onclick="goTo('{{link}}');">
- <td>{{template}}</td>
- <td>{{{status}}}</td>
- </tr>
- {{/table}}
- </tbody>
- </table>
-</div>
-
-<script>
-function goTo(link){
- window.location.href = "?do=Translation&page=template&template=" + link;
-}
-</script>