multilingual catchAllRequest issue

Hi all,

I have a multilingual site (two languages). Recently I decided to include the catchAllRequest for maintenance purposes. I am experiencing a translation issue when I turn the maintenance mode on the website remains translated into my defined ‘language’ rather than the ‘sourceLanguage’

I have declared the following configuration:


'sourceLanguage'=>'en',

'language' => 'bg',

I imagine that by default sourceLanguage would be used on all occasions, which seems to be the case so far. However, when I turn on the maintenance mode the application renders in ‘bg’ language, which is undesirable effect no matter what I do. Am I misunderstanding anything or doing something wrong?

I have:


'catchAllRequest'=>array(

                'site/maintenance',

                'lang'=>'en',

        ),

…and I am also using the LangUrlManager extension:


public $languages=array('en','bg');

public $langParam='lang';


public function parseUrl($request){

        $ret=parent::parseUrl($request);


        $userLang=Yii::app()->getRequest()->getPreferredLanguage();

        //if language pass via url use it

        if(isset($_GET[$this->langParam])&&in_array($_GET[$this->langParam],$this->languages)){

            Yii::app()->language=$_GET[$this->langParam];

        //else if preffered language is allowed

        }elseif(in_array($userLang,$this->languages)) {

            Yii::app()->language=$userLang;

        //else use the first language from the list

        }else Yii::app()->language=$this->languages[0];

        

        return $ret;

    }

My browser prefered language is ‘en’.

Thanks in advance for your help.

Regards,

bettor

p.s. Originally I posted this message in the Bugs section but since that section doesn’t get much attention I reposted it here. Original post: http://www.yiiframework.com/forum/index.php?/topic/10941-multilingual-catchallrequest-issue/

Apologies for double posting.

It is actually the other way round: language sets the language your users will see, while sourceLanguage define, what language your source files are in. So no wonder, you get bg, if you set ‘language’=>‘bg’. The question for me rather is: Why does it only happen in maintenance mode? Not sure, what the extension does. Maybe play around with its settings first.

Take a look at processRequest() method when $catchAllRequest is configured. UrlManager::parseUrl() never gets called.

Indeed, this is the case… I will raise a ticket. Thanks for the help.

cheers,

bettor