From 7f76c8e553a498f8235c5fa79622b6d79b86765b Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Wed, 10 Jun 2020 23:14:47 +0200 Subject: 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. --- cli/i18n/I18nData.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cli/i18n/I18nData.php') 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]; } /** -- cgit v1.2.3