diff options
| author | 2018-03-11 10:53:32 +0100 | |
|---|---|---|
| committer | 2018-03-11 10:53:32 +0100 | |
| commit | f4da01294023146cd1f4bc13f1ba5f77702bb41b (patch) | |
| tree | fa865d9277bea7cca4964fcf861a7cece08455ac /cli/manipulate.translation.php | |
| parent | 2f98978f6def423c46fe668b57107b3019b7a744 (diff) | |
Add option to ignore keys in cli tool
Diffstat (limited to 'cli/manipulate.translation.php')
| -rw-r--r-- | cli/manipulate.translation.php | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/cli/manipulate.translation.php b/cli/manipulate.translation.php index 19b229878..35405bb89 100644 --- a/cli/manipulate.translation.php +++ b/cli/manipulate.translation.php @@ -1,6 +1,6 @@ <?php -$options = getopt("a:hk:l:v:"); +$options = getopt("a:hk:l:rv:"); if (array_key_exists('h', $options)) { help(); @@ -10,9 +10,13 @@ if (!array_key_exists('a', $options)) { error('You need to specify the action to perform.'); } -require_once __DIR__ . '/i18n/I18nFile.php'; - -$i18nFile = new I18nFile(); +if ('ignore' === $options['a']) { + require_once __DIR__ . '/i18n/I18nIgnoreFile.php'; + $i18nFile = new I18nIgnoreFile(); +} else { + require_once __DIR__ . '/i18n/I18nFile.php'; + $i18nFile = new I18nFile(); +} $i18nData = $i18nFile->load(); switch ($options['a']) { @@ -44,6 +48,13 @@ switch ($options['a']) { case 'format' : $i18nFile->dump($i18nData); break; + case 'ignore' : + if (array_key_exists('l', $options) && array_key_exists('k', $options)) { + $i18nData->ignore($options['k'], $options['l'], array_key_exists('r', $options)); + } else { + error('You need to specify a valid set of options.'); + } + break; default : help(); } @@ -80,7 +91,7 @@ DESCRIPTION -a=ACTION select the action to perform. Available actions are add, delete, - duplicate, and format. This option is mandatory. + duplicate, format, and ignore. This option is mandatory. -k=KEY select the key to work on. -v=VAL select the value to set. -l=LANG select the language to work on. @@ -105,6 +116,11 @@ Exemple 5: duplicate a key. It duplicates the key from the referential in every Exemple 6: format i18n files. php %1\$s -a format +Exemple 7: ignore a key. It adds the key in the ignore file to mark it as translated. + php %1\$s -a ignore -k my_key -l my_lang + +Exemple 8: revert ignore a key. It removes the key from the ignore file. + php %1\$s -a ignore -r -k my_key -l my_lang\n\n HELP; $file = str_replace(__DIR__ . '/', '', __FILE__); echo sprintf($help, $file); |
