aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2019-12-04 08:27:39 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-12-04 08:27:39 +0100
commit3e49b44839237693ce1a8151325942704917f6c6 (patch)
tree75a1af8089d48d3bb14de2d9d98c503ee76433e2 /cli
parentde2b323847e0a91119625e4f506f51ec9d43872f (diff)
Update i18n cli tools (#2673)
* Update i18n cli tools Few things were bugging me when using the cli tool for i18n. So I've modified the tools to be easier to use. First, the tool automatically adds missing keys to all languages. This way, we always have all keys in all languages. Second, the tool detects all untranslated keys and adds automatically the todo comment after the value. Third, when adding a new key, the key is pushed to all languages at once. There is no need to duplicate it manually. Thus making the duplication process obsolete. Fourth, translation and ignore keys are manipulated at the same time. Thus we don't have obsolete ignored strings anymore. * Add i18n rules I find that having the common rules in the Makefile is easier to use, as long as you know they are here. As it is self documented, people will see the new rules when using make. * Use long parameters in Makefile I find that using long parameters in scripts makes it easier to understand what's going on. So I've switched all short parameters to long one. * Format all i18n files I've used the updated version of the cli tools to have some output that can be consistently formated. This commit is a huge formating commit. Nothing was added but some comments were removed in the process.
Diffstat (limited to 'cli')
-rw-r--r--cli/check.translation.php7
-rw-r--r--cli/i18n/I18nData.php159
-rw-r--r--cli/i18n/I18nFile.php14
-rw-r--r--cli/i18n/I18nFileInterface.php2
-rw-r--r--cli/i18n/I18nIgnoreFile.php7
-rw-r--r--cli/i18n/ignore/en.php20
-rw-r--r--cli/i18n/ignore/fr.php8
-rw-r--r--cli/i18n/ignore/kr.php4
-rw-r--r--cli/i18n/ignore/nl.php12
-rw-r--r--cli/i18n/ignore/oc.php8
-rw-r--r--cli/i18n/ignore/sk.php18
-rw-r--r--cli/i18n/ignore/zh-cn.php4
-rw-r--r--cli/manipulate.translation.php47
13 files changed, 186 insertions, 124 deletions
diff --git a/cli/check.translation.php b/cli/check.translation.php
index 6ebd12973..12655fc8e 100644
--- a/cli/check.translation.php
+++ b/cli/check.translation.php
@@ -1,11 +1,14 @@
<?php
-require_once __DIR__ . '/i18n/I18nFile.php';
require_once __DIR__ . '/i18n/I18nCompletionValidator.php';
+require_once __DIR__ . '/i18n/I18nData.php';
+require_once __DIR__ . '/i18n/I18nFile.php';
+require_once __DIR__ . '/i18n/I18nIgnoreFile.php';
require_once __DIR__ . '/i18n/I18nUsageValidator.php';
$i18nFile = new I18nFile();
-$i18nData = $i18nFile->load();
+$i18nIgnoreFile = new I18nIgnoreFile();
+$i18nData = new I18nData($i18nFile->load(), $i18nIgnoreFile->load());
$options = getopt("dhl:r");
diff --git a/cli/i18n/I18nData.php b/cli/i18n/I18nData.php
index 2178d330d..a6d260a8f 100644
--- a/cli/i18n/I18nData.php
+++ b/cli/i18n/I18nData.php
@@ -5,15 +5,95 @@ class I18nData {
const REFERENCE_LANGUAGE = 'en';
private $data = array();
- private $originalData = array();
+ private $ignore = array();
- public function __construct($data) {
+ public function __construct($data, $ignore) {
$this->data = $data;
- $this->originalData = $data;
+ $this->ignore = $ignore;
+
+ $this->synchonizeKeys();
}
public function getData() {
- return $this->data;
+ $output = array();
+ $reference = $this->getReferenceLanguage();
+ $languages = $this->getNonReferenceLanguages();
+
+ foreach ($reference as $file => $values) {
+ foreach ($values as $key => $value) {
+ $output[static::REFERENCE_LANGUAGE][$file][$key] = $value;
+ foreach ($languages as $language) {
+ if ($this->data[$language][$file][$key] !== $value) {
+ // This value is translated, there is no need to flag it.
+ $output[$language][$file][$key] = $this->data[$language][$file][$key];
+ } elseif (array_key_exists($language, $this->ignore) && in_array($key, $this->ignore[$language])) {
+ // This value is ignored, there is no need to flag it.
+ $output[$language][$file][$key] = $this->data[$language][$file][$key];
+ } else {
+ // This value is not translated nor ignored, it must be flagged.
+ $output[$language][$file][$key] = "{$value} -> todo";
+ }
+ }
+ }
+ }
+
+ return $output;
+ }
+
+ public function getIgnore() {
+ $ignore = array();
+
+ foreach ($this->ignore as $language => $keys) {
+ sort($keys);
+ $ignore[$language] = $keys;
+ }
+
+ return $ignore;
+ }
+
+ private function synchonizeKeys() {
+ $this->addMissingKeysFromReference();
+ $this->removeExtraKeysFromOtherLanguages();
+ $this->removeUnknownIgnoreKeys();
+ }
+
+ private function addMissingKeysFromReference() {
+ $reference = $this->getReferenceLanguage();
+ $languages = $this->getNonReferenceLanguages();
+
+ foreach ($reference as $file => $values) {
+ foreach ($values as $key => $value) {
+ foreach ($languages as $language) {
+ if (!array_key_exists($key, $this->data[$language][$file])) {
+ $this->data[$language][$file][$key] = $value;
+ }
+ }
+ }
+ }
+ }
+
+ private function removeExtraKeysFromOtherLanguages() {
+ $reference = $this->getReferenceLanguage();
+ foreach ($this->getNonReferenceLanguages() as $language) {
+ foreach ($this->getLanguage($language) as $file => $values) {
+ foreach ($values as $key => $value) {
+ if (!array_key_exists($key, $reference[$file])) {
+ unset($this->data[$language][$file][$key]);
+ }
+ }
+ }
+ }
+ }
+
+ private function removeUnknownIgnoreKeys() {
+ $reference = $this->getReferenceLanguage();
+ foreach ($this->ignore as $language => $keys) {
+ foreach ($keys as $index => $key) {
+ if (!array_key_exists($this->getFilenamePrefix($key), $reference) || !array_key_exists($key, $reference[$this->getFilenamePrefix($key)])) {
+ unset($this->ignore[$language][$index]);
+ }
+ }
+ }
}
/**
@@ -29,6 +109,17 @@ class I18nData {
}
/**
+ * Return all available languages without the reference language
+ *
+ * @return array
+ */
+ public function getNonReferenceLanguages() {
+ return array_filter(array_keys($this->data), function ($value) {
+ return static::REFERENCE_LANGUAGE !== $value;
+ });
+ }
+
+ /**
* Add a new language. It's a copy of the reference language.
*
* @param string $language
@@ -42,7 +133,7 @@ class I18nData {
}
/**
- * Add a key in the reference language
+ * Add a new key to all languages.
*
* @param string $key
* @param string $value
@@ -53,7 +144,12 @@ class I18nData {
array_key_exists($key, $this->data[static::REFERENCE_LANGUAGE][$this->getFilenamePrefix($key)])) {
throw new Exception('The selected key already exist.');
}
- $this->data[static::REFERENCE_LANGUAGE][$this->getFilenamePrefix($key)][$key] = $value;
+
+ foreach ($this->getAvailableLanguages() as $language) {
+ if (!array_key_exists($key, $this->data[$language][$this->getFilenamePrefix($key)])) {
+ $this->data[$language][$this->getFilenamePrefix($key)][$key] = $value;
+ }
+ }
}
/**
@@ -76,29 +172,6 @@ class I18nData {
}
/**
- * Duplicate a key from the reference language to all other languages
- *
- * @param string $key
- * @throws Exception
- */
- public function duplicateKey($key) {
- if (!array_key_exists($this->getFilenamePrefix($key), $this->data[static::REFERENCE_LANGUAGE]) ||
- !array_key_exists($key, $this->data[static::REFERENCE_LANGUAGE][$this->getFilenamePrefix($key)])) {
- throw new Exception('The selected key does not exist.');
- }
- $value = $this->data[static::REFERENCE_LANGUAGE][$this->getFilenamePrefix($key)][$key];
- foreach ($this->getAvailableLanguages() as $language) {
- if (static::REFERENCE_LANGUAGE === $language) {
- continue;
- }
- if (array_key_exists($key, $this->data[$language][$this->getFilenamePrefix($key)])) {
- continue;
- }
- $this->data[$language][$this->getFilenamePrefix($key)][$key] = $value;
- }
- }
-
- /**
* Remove a key in all languages
*
* @param string $key
@@ -113,14 +186,13 @@ class I18nData {
if (array_key_exists($key, $this->data[$language][$this->getFilenamePrefix($key)])) {
unset($this->data[$language][$this->getFilenamePrefix($key)][$key]);
}
+ if (array_key_exists($language, $this->ignore) && $position = array_search($key, $this->ignore[$language])) {
+ unset($this->ignore[$language][$position]);
+ }
}
}
/**
- * WARNING! This is valid only for ignore files. It's not the best way to
- * handle that but as it's meant to be used only for the cli tool, there
- * is no point of spending time on making it better than that.
- *
* Ignore a key from a language, or reverse it.
*
* @param string $key
@@ -128,25 +200,20 @@ class I18nData {
* @param boolean $reverse
*/
public function ignore($key, $language, $reverse = false) {
- $index = array_search($key, $this->data[$language]);
+ if (!array_key_exists($language, $this->ignore)) {
+ $this->ignore[$language] = array();
+ }
- if ($index && $reverse) {
- unset($this->data[$language][$index]);
+ $index = array_search($key, $this->ignore[$language]);
+ if (false !== $index && $reverse) {
+ unset($this->ignore[$language][$index]);
return;
}
- if ($index && !$reverse) {
+ if (false !== $index && !$reverse) {
return;
}
- $this->data[$language][] = $key;
- }
- /**
- * Check if the data has changed
- *
- * @return bool
- */
- public function hasChanged() {
- return $this->data !== $this->originalData;
+ $this->ignore[$language][] = $key;
}
public function getLanguage($language) {
diff --git a/cli/i18n/I18nFile.php b/cli/i18n/I18nFile.php
index 56459ce8b..c97520862 100644
--- a/cli/i18n/I18nFile.php
+++ b/cli/i18n/I18nFile.php
@@ -1,6 +1,5 @@
<?php
-require_once __DIR__ . '/I18nData.php';
require_once __DIR__ . '/I18nFileInterface.php';
class I18nFile implements I18nFileInterface{
@@ -27,11 +26,11 @@ class I18nFile implements I18nFileInterface{
}
}
- return new I18nData($i18n);
+ return $i18n;
}
- public function dump(I18nData $i18n) {
- foreach ($i18n->getData() as $language => $file) {
+ public function dump(array $i18n) {
+ foreach ($i18n as $language => $file) {
$dir = $this->i18nPath . DIRECTORY_SEPARATOR . $language;
if (!file_exists($dir)) {
mkdir($dir);
@@ -80,7 +79,7 @@ class I18nFile implements I18nFileInterface{
private function unflatten($translation) {
$a = array();
- ksort($translation);
+ ksort($translation, SORT_NATURAL | SORT_FLAG_CASE);
foreach ($translation as $compoundKey => $value) {
$keys = explode('.', $compoundKey);
array_shift($keys);
@@ -105,17 +104,20 @@ class I18nFile implements I18nFileInterface{
$patterns = array(
'/array \(/',
'/=>\s*array/',
+ '/(\w) {2}/',
'/ {2}/',
+ '/ -> todo\',/',
);
$replacements = array(
'array(',
'=> array',
+ '$1 ',
"\t", // Double quoting is mandatory to have a tab instead of the \t string
+ "',\t// TODO - Translation", // Double quoting is mandatory to have a tab instead of the \t string
);
$translation = preg_replace($patterns, $replacements, $translation);
// Double quoting is mandatory to have new lines instead of \n strings
return sprintf("<?php\n\nreturn %s;\n", $translation);
}
-
}
diff --git a/cli/i18n/I18nFileInterface.php b/cli/i18n/I18nFileInterface.php
index c5aaf9fcd..9e7c41200 100644
--- a/cli/i18n/I18nFileInterface.php
+++ b/cli/i18n/I18nFileInterface.php
@@ -6,5 +6,5 @@ interface I18nFileInterface {
public function load();
- public function dump(I18nData $i18n);
+ public function dump(array $i18n);
}
diff --git a/cli/i18n/I18nIgnoreFile.php b/cli/i18n/I18nIgnoreFile.php
index 714e000ca..a05a3d5e8 100644
--- a/cli/i18n/I18nIgnoreFile.php
+++ b/cli/i18n/I18nIgnoreFile.php
@@ -1,6 +1,5 @@
<?php
-require_once __DIR__ . '/I18nData.php';
require_once __DIR__ . '/I18nFileInterface.php';
class I18nIgnoreFile implements I18nFileInterface {
@@ -11,8 +10,8 @@ class I18nIgnoreFile implements I18nFileInterface {
$this->i18nPath = __DIR__ . '/ignore';
}
- public function dump(I18nData $i18n) {
- foreach ($i18n->getData() as $language => $content) {
+ public function dump(array $i18n) {
+ foreach ($i18n as $language => $content) {
$filename = $this->i18nPath . DIRECTORY_SEPARATOR . $language . '.php';
file_put_contents($filename, $this->format($content));
}
@@ -28,7 +27,7 @@ class I18nIgnoreFile implements I18nFileInterface {
$i18n[$file->getBasename('.php')] = (include $file->getPathname());
}
- return new I18nData($i18n);
+ return $i18n;
}
/**
diff --git a/cli/i18n/ignore/en.php b/cli/i18n/ignore/en.php
index db5a06a5e..78018bea1 100644
--- a/cli/i18n/ignore/en.php
+++ b/cli/i18n/ignore/en.php
@@ -49,6 +49,12 @@ return array(
'conf.query.order_desc',
'conf.query.state_0',
'conf.query.state_1',
+ 'conf.query.state_10',
+ 'conf.query.state_11',
+ 'conf.query.state_12',
+ 'conf.query.state_13',
+ 'conf.query.state_14',
+ 'conf.query.state_15',
'conf.query.state_2',
'conf.query.state_3',
'conf.query.state_4',
@@ -57,12 +63,6 @@ return array(
'conf.query.state_7',
'conf.query.state_8',
'conf.query.state_9',
- 'conf.query.state_10',
- 'conf.query.state_11',
- 'conf.query.state_12',
- 'conf.query.state_13',
- 'conf.query.state_14',
- 'conf.query.state_15',
'conf.sharing.blogotext',
'conf.sharing.diaspora',
'conf.sharing.email',
@@ -83,20 +83,20 @@ return array(
'gen.lang.ru',
'gen.lang.tr',
'gen.lang.zh-cn',
+ 'gen.share.Known',
'gen.share.blogotext',
'gen.share.diaspora',
'gen.share.email',
'gen.share.facebook',
+ 'gen.share.gnusocial',
+ 'gen.share.jdh',
+ 'gen.share.lemmy',
'gen.share.movim',
'gen.share.print',
'gen.share.shaarli',
'gen.share.twitter',
'gen.share.wallabag',
'gen.share.wallabagv2',
- 'gen.share.jdh',
- 'gen.share.Known',
- 'gen.share.gnusocial',
- 'gen.share.lemmy',
'index.menu.non-starred',
'index.menu.read',
'index.menu.starred',
diff --git a/cli/i18n/ignore/fr.php b/cli/i18n/ignore/fr.php
index 8ed8ffff1..a121e5502 100644
--- a/cli/i18n/ignore/fr.php
+++ b/cli/i18n/ignore/fr.php
@@ -34,20 +34,20 @@ return array(
'gen.share.blogotext',
'gen.share.diaspora',
'gen.share.facebook',
+ 'gen.share.gnusocial',
+ 'gen.share.jdh',
+ 'gen.share.lemmy',
'gen.share.movim',
'gen.share.shaarli',
'gen.share.twitter',
'gen.share.wallabag',
'gen.share.wallabagv2',
- 'gen.share.jdh',
- 'gen.share.gnusocial',
- 'gen.share.lemmy',
'index.about.agpl3',
'index.about.version',
'index.log._',
'index.log.title',
- 'install.title',
'install.this_is_the_end',
+ 'install.title',
'sub.bookmarklet.title',
'sub.feed.description',
'sub.feed.number_entries',
diff --git a/cli/i18n/ignore/kr.php b/cli/i18n/ignore/kr.php
index 2fa867cbe..9fd7a6ff0 100644
--- a/cli/i18n/ignore/kr.php
+++ b/cli/i18n/ignore/kr.php
@@ -19,6 +19,7 @@ return array(
'gen.date.Nov',
'gen.date.Oct',
'gen.date.Sep',
+ 'gen.freshrss._',
'gen.lang.cz',
'gen.lang.de',
'gen.lang.en',
@@ -33,13 +34,13 @@ return array(
'gen.lang.ru',
'gen.lang.tr',
'gen.lang.zh-cn',
- 'gen.freshrss._',
'gen.share.Known',
'gen.share.blogotext',
'gen.share.diaspora',
'gen.share.facebook',
'gen.share.gnusocial',
'gen.share.jdh',
+ 'gen.share.lemmy',
'gen.share.linkedin',
'gen.share.mastodon',
'gen.share.movim',
@@ -49,7 +50,6 @@ return array(
'gen.share.twitter',
'gen.share.wallabag',
'gen.share.wallabagv2',
- 'gen.share.lemmy',
'index.about.agpl3',
'sub.api.title',
);
diff --git a/cli/i18n/ignore/nl.php b/cli/i18n/ignore/nl.php
index dc4dd9356..1a3221003 100644
--- a/cli/i18n/ignore/nl.php
+++ b/cli/i18n/ignore/nl.php
@@ -11,8 +11,6 @@ return array(
'conf.sharing.shaarli',
'conf.sharing.twitter',
'conf.sharing.wallabag',
- 'install.bdd._',
- 'install.bdd.host',
'gen.date.Apr',
'gen.date.Dec',
'gen.date.Nov',
@@ -35,8 +33,10 @@ return array(
'gen.lang.zh-cn',
'gen.share.blogotext',
'gen.share.diaspora',
- 'gen.share.facebook',
'gen.share.email',
+ 'gen.share.facebook',
+ 'gen.share.gnusocial',
+ 'gen.share.jdh',
'gen.share.lemmy',
'gen.share.linkedin',
'gen.share.mastodon',
@@ -48,12 +48,12 @@ return array(
'gen.share.twitter',
'gen.share.wallabag',
'gen.share.wallabagv2',
- 'gen.share.jdh',
- 'gen.share.gnusocial',
'gen.short.ok',
'index.about.agpl3',
- 'index.about.website',
'index.about.version',
+ 'index.about.website',
+ 'install.bdd._',
+ 'install.bdd.host',
'sub.api.title',
'sub.bookmarklet.title',
);
diff --git a/cli/i18n/ignore/oc.php b/cli/i18n/ignore/oc.php
index b67b277fe..fed73078e 100644
--- a/cli/i18n/ignore/oc.php
+++ b/cli/i18n/ignore/oc.php
@@ -35,20 +35,20 @@ return array(
'gen.share.blogotext',
'gen.share.diaspora',
'gen.share.facebook',
+ 'gen.share.gnusocial',
+ 'gen.share.jdh',
+ 'gen.share.lemmy',
'gen.share.movim',
'gen.share.shaarli',
'gen.share.twitter',
'gen.share.wallabag',
'gen.share.wallabagv2',
- 'gen.share.jdh',
- 'gen.share.gnusocial',
- 'gen.share.lemmy',
'index.about.agpl3',
'index.about.version',
'index.log._',
'index.log.title',
- 'install.title',
'install.this_is_the_end',
+ 'install.title',
'sub.bookmarklet.title',
'sub.feed.description',
'sub.feed.number_entries',
diff --git a/cli/i18n/ignore/sk.php b/cli/i18n/ignore/sk.php
index 47d20f81f..244c22dbe 100644
--- a/cli/i18n/ignore/sk.php
+++ b/cli/i18n/ignore/sk.php
@@ -9,12 +9,13 @@ return array(
'conf.sharing.shaarli',
'conf.sharing.twitter',
'conf.sharing.wallabag',
- 'gen.freshrss._',
- 'gen.date.apr',
'gen.date.Aug',
+ 'gen.date.Dec',
+ 'gen.date.Nov',
+ 'gen.date.Sep',
+ 'gen.date.apr',
'gen.date.aug',
'gen.date.august',
- 'gen.date.Dec',
'gen.date.dec',
'gen.date.december',
'gen.date.feb',
@@ -22,12 +23,11 @@ return array(
'gen.date.format_date_hour',
'gen.date.jan',
'gen.date.mar',
- 'gen.date.Nov',
'gen.date.nov',
'gen.date.november',
- 'gen.date.Sep',
'gen.date.sep',
'gen.date.september',
+ 'gen.freshrss._',
'gen.lang.cz',
'gen.lang.de',
'gen.lang.en',
@@ -40,13 +40,15 @@ return array(
'gen.lang.oc',
'gen.lang.pt-br',
'gen.lang.ru',
- 'gen.lang.tr',
'gen.lang.sk',
+ 'gen.lang.tr',
'gen.lang.zh-cn',
'gen.share.blogotext',
'gen.share.diaspora',
- 'gen.share.facebook',
'gen.share.email',
+ 'gen.share.facebook',
+ 'gen.share.gnusocial',
+ 'gen.share.jdh',
'gen.share.linkedin',
'gen.share.mastodon',
'gen.share.movim',
@@ -57,8 +59,6 @@ return array(
'gen.share.twitter',
'gen.share.wallabag',
'gen.share.wallabagv2',
- 'gen.share.jdh',
- 'gen.share.gnusocial',
'index.about.agpl3',
'sub.api.title',
'sub.import_export.title',
diff --git a/cli/i18n/ignore/zh-cn.php b/cli/i18n/ignore/zh-cn.php
index e0209d475..382bb7303 100644
--- a/cli/i18n/ignore/zh-cn.php
+++ b/cli/i18n/ignore/zh-cn.php
@@ -8,6 +8,7 @@ return array(
'conf.sharing.shaarli',
'conf.sharing.twitter',
'conf.sharing.wallabag',
+ 'gen.freshrss._',
'gen.lang.cz',
'gen.lang.de',
'gen.lang.en',
@@ -28,6 +29,7 @@ return array(
'gen.share.facebook',
'gen.share.gnusocial',
'gen.share.jdh',
+ 'gen.share.lemmy',
'gen.share.linkedin',
'gen.share.mastodon',
'gen.share.movim',
@@ -37,8 +39,6 @@ return array(
'gen.share.twitter',
'gen.share.wallabag',
'gen.share.wallabagv2',
- 'gen.share.lemmy',
'index.about.agpl3',
'sub.api.title',
- 'gen.freshrss._',
);
diff --git a/cli/manipulate.translation.php b/cli/manipulate.translation.php
index 35405bb89..c6aa328d9 100644
--- a/cli/manipulate.translation.php
+++ b/cli/manipulate.translation.php
@@ -1,5 +1,9 @@
<?php
+require_once __DIR__ . '/i18n/I18nData.php';
+require_once __DIR__ . '/i18n/I18nFile.php';
+require_once __DIR__ . '/i18n/I18nIgnoreFile.php';
+
$options = getopt("a:hk:l:rv:");
if (array_key_exists('h', $options)) {
@@ -10,14 +14,9 @@ if (!array_key_exists('a', $options)) {
error('You need to specify the action to perform.');
}
-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();
+$data = new I18nFile();
+$ignore = new I18nIgnoreFile();
+$i18nData = new I18nData($data->load(), $ignore->load());
switch ($options['a']) {
case 'add' :
@@ -29,6 +28,7 @@ switch ($options['a']) {
$i18nData->addLanguage($options['l']);
} else {
error('You need to specify a valid set of options.');
+ exit;
}
break;
case 'delete' :
@@ -36,32 +36,26 @@ switch ($options['a']) {
$i18nData->removeKey($options['k']);
} else {
error('You need to specify the key to delete.');
- }
- break;
- case 'duplicate' :
- if (array_key_exists('k', $options)) {
- $i18nData->duplicateKey($options['k']);
- } else {
- error('You need to specify the key to duplicate');
+ exit;
}
break;
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.');
+ exit;
}
break;
default :
help();
+ exit;
}
-if ($i18nData->hasChanged()) {
- $i18nFile->dump($i18nData);
-}
+$data->dump($i18nData->getData());
+$ignore->dump($i18nData->getIgnore());
/**
* Output error message.
@@ -91,7 +85,7 @@ DESCRIPTION
-a=ACTION
select the action to perform. Available actions are add, delete,
- duplicate, format, and ignore. This option is mandatory.
+ 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.
@@ -101,25 +95,22 @@ EXEMPLE
Exemple 1: add a language. It adds a new language by duplicating the referential.
php %1\$s -a add -l my_lang
-Exemple 2: add a new key. It adds the key in the referential.
+Exemple 2: add a new key. It adds the key for all supported languages.
php %1\$s -a add -k my_key -v my_value
Exemple 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
-Exemple 4: delete a key. It deletes the selected key in every languages.
+Exemple 4: delete a key. It deletes the selected key from all supported languages.
php %1\$s -a delete -k my_key
-Exemple 5: duplicate a key. It duplicates the key from the referential in every languages.
- php %1\$s -a duplicate -k my_key
-
-Exemple 6: format i18n files.
+Exemple 5: 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.
+Exemple 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
-Exemple 8: revert ignore a key. It removes the key from the ignore file.
+Exemple 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\n\n
HELP;
$file = str_replace(__DIR__ . '/', '', __FILE__);