Enh: Improved support of languages unsupported Yii2

This commit is contained in:
Lucas Bartholemy 2018-08-13 18:20:45 +02:00
parent b767ded5ec
commit 2afb228489
4 changed files with 23 additions and 2 deletions

View File

@ -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);
}

View File

@ -84,6 +84,10 @@ $config = [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@humhub/messages'
],
'humhub.yii' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@humhub/messages'
],
],
],
'formatter' => [

View File

@ -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)

View File

@ -0,0 +1,3 @@
<?php
return [];