summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-08-19 12:45:03 -0700
committerFrédéric Guillot <fred@kanboard.net>2014-08-19 12:45:03 -0700
commitc4ddc8031f4fd12345a326697439c6136cb59dbd (patch)
treeab937369f60e2f43ce003d1710ed400bed4970b1 /scripts
parent9bfb6c4c4ba16378201564118ddc4c25eb83a0b1 (diff)
Add Italian translation and synchronize locale files
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/sync-locales.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/sync-locales.php b/scripts/sync-locales.php
new file mode 100755
index 00000000..00d6c897
--- /dev/null
+++ b/scripts/sync-locales.php
@@ -0,0 +1,43 @@
+#!/usr/bin/env php
+<?php
+
+$reference_lang = 'fr_FR';
+$reference_file = 'app/Locales/'.$reference_lang.'/translations.php';
+$reference = include $reference_file;
+
+
+function update_missing_locales(array $reference, $outdated_file)
+{
+ $outdated = include $outdated_file;
+
+ $output = '<?php'.PHP_EOL.PHP_EOL;
+ $output .= 'return array('.PHP_EOL;
+
+ foreach ($reference as $key => $value) {
+
+ if (isset($outdated[$key])) {
+ //$output .= " '".str_replace("'", "\'", $key)."' => '".str_replace("'", "\'", $value)."',\n";
+ $output .= " '".str_replace("'", "\'", $key)."' => '".str_replace("'", "\'", $outdated[$key])."',\n";
+ }
+ else {
+ //$output .= " // '".str_replace("'", "\'", $key)."' => '".str_replace("'", "\'", $value)."',\n";
+ $output .= " // '".str_replace("'", "\'", $key)."' => '',\n";
+ }
+ }
+
+ $output .= ");\n";
+ return $output;
+}
+
+
+foreach (new DirectoryIterator('app/Locales') as $fileInfo) {
+
+ if (! $fileInfo->isDot() && $fileInfo->isDir() && $fileInfo->getFilename() !== $reference_lang) {
+
+ $filename = 'app/Locales/'.$fileInfo->getFilename().'/translations.php';
+
+ echo $fileInfo->getFilename().' ('.$filename.')'.PHP_EOL;
+
+ file_put_contents($filename, update_missing_locales($reference, $filename));
+ }
+}