Multiple Languages And The Urlmanager


I’m building an application that will be used for multiple languages. But not one website that has multiple languages, but multiple websites that are in a particular language. But the websites are the same except the language, so I want to develop just one webapp and change the ‘language’=>‘en’ option in the config for every website.

I read about the i18n options that Yii offers and they are covering a lot the I need.

The only thing I can’t figure out is the rules for the UrlManager.

Is there a way I can have a file for every language that contains the rules for the UrlManager? Just like I have different view files for every language?

The reason is that I want the complete URL to be locale for every website.

Do you know the solution for me or do you know a better approach for me?


If you only have to set the Yii::app()->language different for every website you can do like this:

Define a constant in your index.php depending on the (virtual) host:



    case 'localhost':



    case '':



    case '':








In the config/main.php

  return array(




If there are more differences in config, similar to above you define a configfile, depending on the server host in the switch.

Assign the ‘language-config’ or merge it with a basic config for all sites like described here (Section Application Configurations):

That’s a simple and elegant solution, I can work with something like this. I was looking for something too complicated I guess. Thanks!