diff options
| author | 2017-12-17 20:28:04 +0100 | |
|---|---|---|
| committer | 2017-12-17 20:28:04 +0100 | |
| commit | 60f56539c3f30fd3f7ba4f2a3570f7029ac93e5f (patch) | |
| tree | 1e78bfac7042dceb63898e2215db8fb0c1d7745d /cli/manipulate.translation.php | |
| parent | ceda55c75b158fc1cf4813fe0f258527754b9289 (diff) | |
| parent | 0b1516af91792f86868689392f72ad4b6e32cdcf (diff) | |
Merge pull request #1720 from FreshRSS/dev
FreshRSS 1.9.0
Diffstat (limited to 'cli/manipulate.translation.php')
| -rw-r--r-- | cli/manipulate.translation.php | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/cli/manipulate.translation.php b/cli/manipulate.translation.php new file mode 100644 index 000000000..aace5723a --- /dev/null +++ b/cli/manipulate.translation.php @@ -0,0 +1,79 @@ +<?php + +$options = getopt("h"); + +if (array_key_exists('h', $options)) { + help(); +} + +if (1 === $argc || 4 < $argc) { + help(); +} + +require_once __DIR__ . '/i18n/I18nFile.php'; + +$i18nFile = new I18nFile(); +$i18nData = $i18nFile->load(); + +switch ($argv[1]) { + case 'add_language' : + $i18nData->addLanguage($argv[2]); + break; + case 'add_key' : + if (3 === $argc) { + help(); + } + $i18nData->addKey($argv[2], $argv[3]); + break; + case 'duplicate_key' : + $i18nData->duplicateKey($argv[2]); + break; + case 'delete_key' : + $i18nData->removeKey($argv[2]); + break; + default : + help(); +} + +if ($i18nData->hasChanged()) { + $i18nFile->dump($i18nData); +} + +/** + * Output help message. + */ +function help() { + $help = <<<HELP +NAME + %s + +SYNOPSIS + php %s [OPTION] [OPERATION] [KEY] [VALUE] + +DESCRIPTION + Manipulate translation files. Available operations are + Check if translation files have missing keys or missing translations. + + -h display this help and exit. + +OPERATION + add_language + add a new language by duplicating the referential. This operation + needs only a KEY. + + add_key add a new key in the referential. This operation needs a KEY and + a VALUE. + + duplicate_key + duplicate a referential key in other languages. This operation + needs only a KEY. + + delete_key + delete a referential key from all languages. This operation needs + only a KEY. + +HELP; + $file = str_replace(__DIR__ . '/', '', __FILE__); + echo sprintf($help, $file, $file); + exit; +} |
