diff --git a/protected/humhub/components/i18n/I18N.php b/protected/humhub/components/i18n/I18N.php index 6f033d2244..af3c5c220d 100644 --- a/protected/humhub/components/i18n/I18N.php +++ b/protected/humhub/components/i18n/I18N.php @@ -8,8 +8,8 @@ namespace humhub\components\i18n; -use Yii; use humhub\models\forms\ChooseLanguage; +use Yii; use yii\base\InvalidParamException; /** @@ -25,6 +25,15 @@ class I18N extends \yii\i18n\I18N */ public $messageOverwritePath = '@config/messages'; + /** + * Languages which are not supported by Yii. + * To overwrite this languages, a language file called "humhub.yii.php" + * needs to be placed in the messages folder. + * + * @var array list of languages + */ + public $unsupportedYiiLanguages = ['an']; + /** * Automatically sets the current locale and time zone */ @@ -99,7 +108,7 @@ class I18N extends \yii\i18n\I18N */ public function setDefaultLocale() { - $this->setLocale( Yii::$app->settings->get('defaultLanguage')); + $this->setLocale(Yii::$app->settings->get('defaultLanguage')); $this->fixLocaleCodes(); } @@ -136,6 +145,10 @@ class I18N extends \yii\i18n\I18N $language = 'nb-NO'; } + if ($category === 'yii' && in_array($language, $this->unsupportedYiiLanguages)) { + $category = 'humhub.yii'; + } + return parent::translate($category, $message, $params, $language); } diff --git a/protected/humhub/config/common.php b/protected/humhub/config/common.php index 8a2f5fc1f0..69928dea76 100644 --- a/protected/humhub/config/common.php +++ b/protected/humhub/config/common.php @@ -84,6 +84,10 @@ $config = [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => '@humhub/messages' ], + 'humhub.yii' => [ + 'class' => 'yii\i18n\PhpMessageSource', + 'basePath' => '@humhub/messages' + ], ], ], 'formatter' => [ diff --git a/protected/humhub/docs/CHANGELOG.md b/protected/humhub/docs/CHANGELOG.md index 6c31ce5763..dfb5391762 100644 --- a/protected/humhub/docs/CHANGELOG.md +++ b/protected/humhub/docs/CHANGELOG.md @@ -9,6 +9,7 @@ HumHub Change Log - Fix: No e-mail summary immediately after installation - Enh: Added queuing for search updates of commments - Enh: Added queue clear option at Administration - Information +- Enh: Improved support of languages unsupported Yii2 1.3.1 (August 7, 2018) diff --git a/protected/humhub/messages/an/humhub.yii.php b/protected/humhub/messages/an/humhub.yii.php new file mode 100644 index 0000000000..0b67a5fe47 --- /dev/null +++ b/protected/humhub/messages/an/humhub.yii.php @@ -0,0 +1,3 @@ +