Multiple Languages And The Urlmanager

Hi,

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?

Thanks!

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:





switch($_SERVER['HTTP_HOST'])

{

    case 'localhost':

       define('SITELANGUAGE','de');

       break;

    case 'frenchdomain.com':

       define('SITELANGUAGE','fr');

       break;

    case 'italian.domain.com':

       define('SITELANGUAGE','it');

       break;


    default:

        define('SITELANGUAGE','en');

}


....

Yii::createWebApplication($config)->run();




In the config/main.php




  return array(

    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

    'language'=>SITELANGUAGE,

    ...




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):

http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site

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