diff options
author | nikrou <nikrou@piwigo.org> | 2010-03-23 16:19:13 +0000 |
---|---|---|
committer | nikrou <nikrou@piwigo.org> | 2010-03-23 16:19:13 +0000 |
commit | cd0c4ae7dd3fdc9266ee834ce8348c962877945e (patch) | |
tree | f1eeee0e6ea71ed729ee3ba25578784f6841fb30 /tools/replace.php | |
parent | 658d979d7eb1e52202ab0849f796c2e2aff9cddd (diff) |
Fix missing key translations for nbm and c13y
git-svn-id: http://piwigo.org/svn/trunk@5287 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'tools/replace.php')
-rwxr-xr-x | tools/replace.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/replace.php b/tools/replace.php new file mode 100755 index 000000000..21d38c0e4 --- /dev/null +++ b/tools/replace.php @@ -0,0 +1,53 @@ +#!/usr/bin/php -qn +<?php +if (isset($_SERVER['argc']) && $_SERVER['argc']<=1) +{ + echo "\n"; + echo 'usage : ', basename($_SERVER['argv'][0]), " <filename>\n"; + echo "\n"; + exit(1); +} + +$filename = trim($_SERVER['argv'][1]); +$lines = file($filename); +$content = file_get_contents($filename); + +$n = 0; +$nbLines = count($lines); + +$pattern = "`(.*{')(.*)('\|@translate}.*)`Um"; +$replace = "'{\''.keyReplace('\\1').'\'|@translate}'"; + +include "language/en_UK/common.lang.php"; +include "language/en_UK/admin.lang.php"; +include "language/en_UK/upgrade.lang.php"; +include "language/en_UK/install.lang.php"; + +while ($n < $nbLines) { + preg_match_all($pattern, $lines[$n], $matches); + echo str_replace($matches[2], keyReplace($matches[2]), $lines[$n]); + $n++; +} + +function keyReplace($key) { + global $lang; + + if (is_array($key)) { + $translation = array(); + foreach ($key as $i => $k) { + if (isset($lang[$k])) { + $translation = addslashes($lang[$k]); + } else { + $translation = "$k"; + } + } + } else { + if (isset($lang[$key])) { + $translation = addslashes($lang[$key]); + } else { + $translation = "$key"; + } + } + return $translation; +} +?>
\ No newline at end of file |