aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2019-12-18 09:26:17 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2019-12-18 09:26:17 +0100
commit2b1f8e67f76672a5b1b0a1b0403d81dbee364c58 (patch)
treeab3142289e260111c686e740b9f4214453a0a84c /cli
parent90c7292326538522a5df97b3f0a847b8a28f759f (diff)
parent82851d2039f619f1b2558e06b04a9e47fceeea54 (diff)
Merge branch 'dev'
This is the end of the `dev` branch. Good bye old friend!
Diffstat (limited to 'cli')
-rw-r--r--cli/README.md2
-rw-r--r--cli/_update-or-create-user.php3
-rw-r--r--cli/check.translation.php7
-rwxr-xr-xcli/create-user.php1
-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.php9
-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
-rwxr-xr-xcli/translation-update.sh38
-rwxr-xr-xcli/update-user.php1
18 files changed, 227 insertions, 129 deletions
diff --git a/cli/README.md b/cli/README.md
index 89b440a39..4ef665e69 100644
--- a/cli/README.md
+++ b/cli/README.md
@@ -127,5 +127,5 @@ Example to get the number of feeds of a given user:
# Install and updates
-If you want to administrate FreshRSS using git, please read our [installation docs](https://freshrss.github.io/FreshRSS/en/admins/02_Installation.html)
+If you want to administrate FreshRSS using git, please read our [installation docs](https://freshrss.github.io/FreshRSS/en/admins/03_Installation.html)
and [update guidelines](https://freshrss.github.io/FreshRSS/en/admins/03_Updating.html).
diff --git a/cli/_update-or-create-user.php b/cli/_update-or-create-user.php
index 43b86a4a9..3217a07ea 100644
--- a/cli/_update-or-create-user.php
+++ b/cli/_update-or-create-user.php
@@ -4,7 +4,6 @@ require(__DIR__ . '/_cli.php');
$params = array(
'user:',
'password:',
- 'api_password:',
'language:',
'email:',
'token:',
@@ -24,7 +23,7 @@ $options = getopt('', $params);
if (!validateOptions($argv, $params) || empty($options['user'])) {
fail('Usage: ' . basename($_SERVER['SCRIPT_FILENAME']) .
- " --user username ( --password 'password' --api_password 'api_password'" .
+ " --user username ( --password 'password'" .
" --language en --email user@example.net --token 'longRandomString'" .
($isUpdate ? '' : '--no_default_feeds') .
" --purge_after_months 3 --feed_min_articles_default 50 --feed_ttl_default 3600" .
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/create-user.php b/cli/create-user.php
index 7e0a031d9..9e978ee3c 100755
--- a/cli/create-user.php
+++ b/cli/create-user.php
@@ -20,7 +20,6 @@ $ok = FreshRSS_user_Controller::createUser(
$username,
empty($options['mail_login']) ? '' : $options['mail_login'],
empty($options['password']) ? '' : $options['password'],
- empty($options['api_password']) ? '' : $options['api_password'],
$values,
!isset($options['no_default_feeds'])
);
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..d7e54ed98 100644
--- a/cli/i18n/ignore/fr.php
+++ b/cli/i18n/ignore/fr.php
@@ -3,6 +3,7 @@
return array(
'admin.extensions.title',
'admin.stats.number_entries',
+ 'admin.user.article_count',
'admin.user.articles_and_size',
'conf.display.width.large',
'conf.sharing.blogotext',
@@ -34,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/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__);
diff --git a/cli/translation-update.sh b/cli/translation-update.sh
new file mode 100755
index 000000000..9847dc4e0
--- /dev/null
+++ b/cli/translation-update.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+# This script performs the following:
+# - Generate configuration file for po4a (can be configured in CONFIGFILE)
+# - Generate POT file from pages/<DIRECTORY>/*.md
+# - Update PO files in i18n directory with POT file
+# - Generate localized pages.XX/<DIRECTORY>/*.md (where XX is the language code)
+# - Remove unneeded new lines from generated pages
+
+# Name of the po4a configuration file
+CONFIGFILE='po4a.conf'
+
+# List of supported languages
+LANGS=(fr)
+
+# Check if po4a is installed
+if [ -z "$(command -v po4a)" ]; then
+ echo 'It seems that po4a is not installed on your system.'
+ echo 'Please install po4a to use this script.'
+ exit 1
+fi
+
+# Generate po4a.conf file with list of TLDR pages
+echo 'Generating configuration file for po4a...'
+{
+ echo '# WARNING: this file is generated with translation-update.sh'
+ echo '# DO NOT modify this file manually!'
+ echo "[po4a_langs] ${LANGS[*]}"
+ # shellcheck disable=SC2016
+ echo '[po4a_paths] i18n/templates/freshrss.pot $lang:i18n/freshrss.$lang.po'
+} >$CONFIGFILE
+
+for FILE in $(cd en && tree -f -i | grep ".md" | grep -v "admins"); do
+ echo "[type: text] en/$FILE \$lang:\$lang/$FILE opt:\"-o markdown\" opt:\"-M utf-8\"" >>$CONFIGFILE
+done
+
+# Generate POT file, PO files, and pages.XX pages
+echo 'Generating POT file and translated pages...'
+po4a -k 0 --msgid-bugs-address 'https://github.com/FreshRSS/FreshRSS/issues' $CONFIGFILE
diff --git a/cli/update-user.php b/cli/update-user.php
index 8067dadd3..02da16d5a 100755
--- a/cli/update-user.php
+++ b/cli/update-user.php
@@ -11,7 +11,6 @@ $ok = FreshRSS_user_Controller::updateUser(
$username,
empty($options['mail_login']) ? null : $options['mail_login'],
empty($options['password']) ? '' : $options['password'],
- empty($options['api_password']) ? '' : $options['api_password'],
$values);
if (!$ok) {