summaryrefslogtreecommitdiffstats
path: root/modules-available/translation
diff options
context:
space:
mode:
authorSimon Rettberg2018-03-21 11:47:27 +0100
committerSimon Rettberg2018-03-21 11:47:27 +0100
commit41ac58d665ac9b4342f485db6932b4320084e4fe (patch)
tree83d6011a07f86784a746d62f878e271809a204fd /modules-available/translation
parentUpdate translations (diff)
downloadslx-admin-41ac58d665ac9b4342f485db6932b4320084e4fe.tar.gz
slx-admin-41ac58d665ac9b4342f485db6932b4320084e4fe.tar.xz
slx-admin-41ac58d665ac9b4342f485db6932b4320084e4fe.zip
[translation] Fix tag collision for messages
Diffstat (limited to 'modules-available/translation')
-rw-r--r--modules-available/translation/page.inc.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/modules-available/translation/page.inc.php b/modules-available/translation/page.inc.php
index bd5d440e..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);