diff options
Diffstat (limited to 'modules-available/translation')
-rw-r--r-- | modules-available/translation/page.inc.php | 21 | ||||
-rw-r--r-- | modules-available/translation/templates/edit.html | 4 |
2 files changed, 14 insertions, 11 deletions
diff --git a/modules-available/translation/page.inc.php b/modules-available/translation/page.inc.php index df7bc15e..7d5229d7 100644 --- a/modules-available/translation/page.inc.php +++ b/modules-available/translation/page.inc.php @@ -464,19 +464,21 @@ class Page_Translation extends Page $allFiles = array_merge($allFiles, $this->getAllFiles('apis', '.php'), $this->getAllFiles('inc', '.php')); $allFiles[] = 'index.php'; } - $tags = $this->loadTagsFromPhp('/Message\s*::\s*add\w+\s*\(\s*[\'"](?<module>[^\'"\.]*)\.(?<tag>[^\'"]*)[\'"]\s*(?<data>\)|\,.*)/i', + $full = $this->loadTagsFromPhp('/Message\s*::\s*add\w+\s*\(\s*[\'"](?<tag>[^\'"\.]*\.[^\'"]*)[\'"]\s*(?<data>\)|\,.*)/i', $allFiles); + $tags = []; // Filter out tags that don't refer to this module - foreach (array_keys($tags) as $tag) { + foreach ($full as $tag) { + $p = explode('.', $tag['tag'], 2); // Figure out if this is a message from this module or not - if ($tags[$tag]['module'] === $module->getIdentifier()) { + if ($p[0] === $module->getIdentifier()) { // Direct reference to this module via module.id - continue; + $tag['tag'] = $p[1]; + $tags[$p[1]] = $tag; } - unset($tags[$tag]); } - $tags += $this->loadTagsFromPhp('/Message\s*::\s*add\w+\s*\(\s*[\'"](?<tag>[^\'"\.]*)[\'"]\s*(?<data>\)|\,.*)/i', - $this->getModulePhpFiles($module)); + $tags = $this->loadTagsFromPhp('/Message\s*::\s*add\w+\s*\(\s*[\'"](?<tag>[^\'"\.]*)[\'"]\s*(?<data>\)|\,.*)/i', + $this->getModulePhpFiles($module), $tags); return $tags; } @@ -831,12 +833,12 @@ class Page_Translation extends Page * * @param string $regexp regular expression * @param array $files list of files to scan + * @param array $tags existing tag array to append to * @return array of all tags found, where the tag is the key, and the value is as described above */ - private function loadTagsFromPhp($regexp, $files) + private function loadTagsFromPhp($regexp, $files, $tags = []) { // Get all php files, so we can find all strings that need to be translated - $tags = array(); // Now find all tags in all php files. Only works for literal usage, not something like $foo = 'bar'; Dictionary::translate($foo); foreach ($files as $file) { $content = file_get_contents($file); @@ -999,6 +1001,7 @@ class Page_Translation extends Page //find the tag requests to change the file $tags = Request::post('langtag', array(), 'array'); foreach ($tags as $tag => $value) { + error_log($tag . '=' . $value); $tag = trim($tag); if (empty($tag)) { Message::addWarning('i18n-empty-tag'); diff --git a/modules-available/translation/templates/edit.html b/modules-available/translation/templates/edit.html index 15e69f3b..5b957067 100644 --- a/modules-available/translation/templates/edit.html +++ b/modules-available/translation/templates/edit.html @@ -38,7 +38,7 @@ <input type="text" class="form-control switchable {{#missing}}txt-empty{{/missing}}" value="{{translation}}" ondblclick="slxMb(this)" name="langtag[{{tag}}]" placeholder="{{placeholder}}"> {{/big}} {{#big}} - <textarea rows="3" class="form-control {{#missing}}txt-empty{{/missing}}" name="lang#!#{{tag}}" placeholder="{{placeholder}}">{{translation}}</textarea> + <textarea rows="3" class="form-control {{#missing}}txt-empty{{/missing}}" name="langtag[{{tag}}]" placeholder="{{placeholder}}">{{translation}}</textarea> {{/big}} </td> @@ -81,7 +81,7 @@ var slxNewTagCounter = 0; function slxAddTag() { - $('#moduleTable tr:last').after( + $('#moduleTable').find('tr:last').after( '<tr id="new-delete-' + slxNewTagCounter + '">' + ' <td class="col-sm-3">' + ' <input type="text" name="new-id[' + slxNewTagCounter + ']" class="form-control">' + |