diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Console/LocaleSync.php | 57 | ||||
-rw-r--r-- | app/Locale/pl_PL/translations.php | 4 |
2 files changed, 59 insertions, 2 deletions
diff --git a/app/Console/LocaleSync.php b/app/Console/LocaleSync.php new file mode 100644 index 00000000..ab95651b --- /dev/null +++ b/app/Console/LocaleSync.php @@ -0,0 +1,57 @@ +<?php + +namespace Console; + +use DirectoryIterator; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class LocaleSync extends Base +{ + const REF_LOCALE = 'fr_FR'; + + protected function configure() + { + $this + ->setName('locale:sync') + ->setDescription('Synchronize all translations based on the '.self::REF_LOCALE.' locale'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $reference_file = 'app/Locale/'.self::REF_LOCALE.'/translations.php'; + $reference = include $reference_file; + + foreach (new DirectoryIterator('app/Locale') as $fileInfo) { + + if (! $fileInfo->isDot() && $fileInfo->isDir() && $fileInfo->getFilename() !== self::REF_LOCALE) { + + $filename = 'app/Locale/'.$fileInfo->getFilename().'/translations.php'; + echo $fileInfo->getFilename().' ('.$filename.')'.PHP_EOL; + + file_put_contents($filename, $this->updateFile($reference, $filename)); + } + } + } + + public function updateFile(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 (! empty($outdated[$key])) { + $output .= " '".str_replace("'", "\'", $key)."' => '".str_replace("'", "\'", $outdated[$key])."',\n"; + } + else { + $output .= " // '".str_replace("'", "\'", $key)."' => '',\n"; + } + } + + $output .= ");\n"; + return $output; + } +} diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index 0bdfe57f..41355c9b 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -787,7 +787,7 @@ return array( 'Custom Stylesheet' => 'Niestandardowy arkusz stylów', 'download' => 'pobierz', 'Do you really want to remove this budget line?' => 'Czy chcesz usunąć tą linię budżetową?', - //'EUR - Euro' => '', + // 'EUR - Euro' => '', 'Expenses' => 'Wydatki', 'GBP - British Pound' => 'GBP - Funt brytyjski', 'INR - Indian Rupee' => 'INR - Rupia indyjska', @@ -797,7 +797,7 @@ return array( 'Remove a budget line' => 'Usuń linię budżetową', 'Remove budget line' => 'Usuń linię budżetową', 'RSD - Serbian dinar' => 'RSD - Dinar serbski', - 'The budget line have been created successfully.' => '', + // 'The budget line have been created successfully.' => '', 'Unable to create the budget line.' => 'Nie można utworzyć linii budżetowej', 'Unable to remove this budget line.' => 'Nie można usunąć tej linii budżetowej', 'USD - US Dollar' => 'USD - Dolar amerykański', |