Added translation callback

This commit is contained in:
Lucas Bartholemy 2019-12-11 17:14:02 +01:00
parent 47463518bc
commit 52c0a9e958

View File

@ -36,6 +36,15 @@ class I18N extends BaseI18N
*/
public $unsupportedYiiLanguages = ['an'];
/**
* Called before the translate method is executed.
* e.g. to modify translations on the fly.
*
* @since 1.4
* @var callable
*/
public $beforeTranslateCallback;
/**
* Automatically sets the current locale and time zone
*/
@ -131,6 +140,11 @@ class I18N extends BaseI18N
$category = 'humhub.yii';
}
if (is_callable($this->beforeTranslateCallback)) {
list($category, $message, $params, $language) =
$this->beforeTranslateCallback->call($this, $category, $message, $params, $language);
}
return parent::translate($category, $message, $params, $language);
}