diff options
| author | 2022-01-08 08:00:26 -0500 | |
|---|---|---|
| committer | 2022-01-08 14:00:26 +0100 | |
| commit | 127b7f0a3aad7012055c058e8aba0d27192a8cbc (patch) | |
| tree | 8ec9a5948672e702c944c202f78294b81104582f /cli/manipulate.translation.php | |
| parent | ed19445f74c30854c60873cd1df1c38e15fc316b (diff) | |
Change i18n process (#4131)
Before, the ignore info were stored in a different file which was a bit cumbersome
for new comers. Now, this info is stored directly in the translation file as a
comment.
Before, there was no way of telling translators that a previously translated string
was in need of a new translation. Now, the dirty information is there to convey that
info.
Diffstat (limited to 'cli/manipulate.translation.php')
| -rwxr-xr-x | cli/manipulate.translation.php | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/cli/manipulate.translation.php b/cli/manipulate.translation.php index 1e9de4385..2b53b8606 100755 --- a/cli/manipulate.translation.php +++ b/cli/manipulate.translation.php @@ -3,7 +3,6 @@ require_once __DIR__ . '/i18n/I18nData.php'; require_once __DIR__ . '/i18n/I18nFile.php'; -require_once __DIR__ . '/i18n/I18nIgnoreFile.php'; $options = getopt("a:hk:l:o:rv:"); @@ -16,8 +15,7 @@ if (!array_key_exists('a', $options)) { } $data = new I18nFile(); -$ignore = new I18nIgnoreFile(); -$i18nData = new I18nData($data->load(), $ignore->load()); +$i18nData = new I18nData($data->load()); switch ($options['a']) { case 'add' : @@ -81,7 +79,6 @@ switch ($options['a']) { } $data->dump($i18nData->getData()); -$ignore->dump($i18nData->getIgnore()); /** * Output error message. @@ -99,19 +96,20 @@ ERROR; * Output help message. */ function help() { - $help = <<<HELP + $file = str_replace(__DIR__ . '/', '', __FILE__); + echo <<<HELP NAME - %1\$s + $file SYNOPSIS - php %1\$s [OPTIONS] + php $file [OPTIONS] DESCRIPTION Manipulate translation files. -a=ACTION select the action to perform. Available actions are add, delete, - exist, format, and ignore. This option is mandatory. + exist, format, ignore, and ignore_unmodified. 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. @@ -121,38 +119,35 @@ DESCRIPTION EXAMPLES Example 1: add a language. It adds a new language by duplicating the referential. - php %1\$s -a add -l my_lang - php %1\$s -a add -l my_lang -o ref_lang + php $file -a add -l my_lang + php $file -a add -l my_lang -o ref_lang Example 2: add a new key. It adds the key for all supported languages. - php %1\$s -a add -k my_key -v my_value + php $file -a add -k my_key -v my_value Example 3: add a new value. It adds a new value for the selected key in the selected language. - php %1\$s -a add -k my_key -v my_value -l my_lang + php $file -a add -k my_key -v my_value -l my_lang Example 4: delete a key. It deletes the selected key from all supported languages. - php %1\$s -a delete -k my_key + php $file -a delete -k my_key Example 5: format i18n files. - php %1\$s -a format + php $file -a format Example 6: 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 + php $file -a ignore -k my_key -l my_lang Example 7: revert ignore a key. It removes the key from the ignore file. - php %1\$s -a ignore -r -k my_key -l my_lang + php $file -a ignore -r -k my_key -l my_lang Example 8: ignore all unmodified keys. It adds all modified keys in the ignore file to mark it as translated. - php %1\$s -a ignore_unmodified -l my_lang + php $file -a ignore_unmodified -l my_lang Example 9: revert ignore of all unmodified keys. It removes the unmodified keys from the ignore file. Warning, this will also revert keys added individually. - php %1\$s -a ignore_unmodified -r -l my_lang + php $file -a ignore_unmodified -r -l my_lang Example 10: check if a key exist. - php %1\$s -a exist -k my_key\n\n + php $file -a exist -k my_key\n\n HELP; - $file = str_replace(__DIR__ . '/', '', __FILE__); - echo sprintf($help, $file); - exit; } |
