diff options
| author | 2020-06-10 23:14:47 +0200 | |
|---|---|---|
| committer | 2020-06-10 23:14:47 +0200 | |
| commit | 7f76c8e553a498f8235c5fa79622b6d79b86765b (patch) | |
| tree | 9e0db10d5ed0e0c96f285db74a5930b274523857 /cli/i18n/I18nData.php | |
| parent | f34f1ff8f119f86a0743f78b1a4cbe31476c5df6 (diff) | |
Add a language reference while adding a new one (#3044)
Before, all new languages were generated from the reference language which
was English. It makes sense for new languages but not so much for new language
flavor (ex: French Canadian versus French French)
Now, there is a way to select the reference language while adding a new one.
Diffstat (limited to 'cli/i18n/I18nData.php')
| -rw-r--r-- | cli/i18n/I18nData.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cli/i18n/I18nData.php b/cli/i18n/I18nData.php index 2f09a5525..5071c9be9 100644 --- a/cli/i18n/I18nData.php +++ b/cli/i18n/I18nData.php @@ -123,13 +123,17 @@ class I18nData { * Add a new language. It's a copy of the reference language. * * @param string $language + * @param string $reference * @throws Exception */ - public function addLanguage($language) { + public function addLanguage($language, $reference = null) { if (array_key_exists($language, $this->data)) { throw new Exception('The selected language already exist.'); } - $this->data[$language] = $this->data[static::REFERENCE_LANGUAGE]; + if (!is_string($reference) && !array_key_exists($reference, $this->data)) { + $reference = static::REFERENCE_LANGUAGE; + } + $this->data[$language] = $this->data[$reference]; } /** |
