miniflux-legacy/scripts/sync-locales.php

42 lines
1.1 KiB
PHP
Raw Normal View History

2014-07-23 12:43:48 +02:00
#!/usr/bin/env php
<?php
$reference_lang = 'fr_FR';
$reference_file = 'locales/'.$reference_lang.'/translations.php';
2014-07-23 12:43:48 +02:00
$reference = include $reference_file;
function update_missing_locales(array $reference, $outdated_file)
{
$outdated = include $outdated_file;
2014-07-23 12:43:48 +02:00
$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("'", "\'", $outdated[$key])."',\n";
}
else {
$output .= " // '".str_replace("'", "\'", $key)."' => '',\n";
}
2014-07-23 12:43:48 +02:00
}
$output .= ");\n";
return $output;
2014-07-23 12:43:48 +02:00
}
foreach (new DirectoryIterator('locales') as $fileInfo) {
if (! $fileInfo->isDot() && $fileInfo->isDir() && $fileInfo->getFilename() !== $reference_lang) {
$filename = 'locales/'.$fileInfo->getFilename().'/translations.php';
echo $fileInfo->getFilename().' ('.$filename.')'.PHP_EOL;
file_put_contents($filename, update_missing_locales($reference, $filename));
}
}