OmgDef / yii2-multilingual-behavior

Yii2 port of the yii-multilingual-behavior.
146 stars 60 forks source link

Bugfix #6

Closed madand closed 9 years ago

madand commented 9 years ago

I use Yii v2.0.1 and encountered the following bug: Suppose we have configured 2 languages: 'uk' and 'ru'. Default app lang is 'uk'. I tried to get localized version in non-default lang like this:

$model = ModelClass::find()->localized('ru')->one();
echo $model->title; // It echoes title in default language, not 'ru'!

I found out that relational query condition value was ['and', ['language'=>'uk'], ['language'=>'ru']] that is, default app laguage (applied in MultilingualBehavior::getTranslation()) was and'd with scope's (MultilingualTrait::localized()) supplied parameter.

Simple fix for this misbehavior attached.

OmgDef commented 9 years ago

Thanks!