diff --git a/protected/humhub/components/i18n/I18N.php b/protected/humhub/components/i18n/I18N.php index 266a436e00..5007ec260b 100644 --- a/protected/humhub/components/i18n/I18N.php +++ b/protected/humhub/components/i18n/I18N.php @@ -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); }