Hello,

I need to configure my site for several domains each of which must turn the corresponding language on. For instance,
www.site.com - en, www.site.ru - ru, www.site.jp - jp, etc...
All of them will point to the same source code and will have the same database. The only difference is default language.

As I understood, each domain will have corresponding settings.php file. I didn't find the way to change default language from within settings.php file.

Can anybody help with this problem?

Thanks.

Comments

mdixoncm’s picture

I've not used it but it might be worth checking out the internationalisation module

http://drupal.org/project/i18n

failing that, I have done a couple of "hacks" in the past by just changing the global $locale variable as required.

Mike,
Are you opinionated? HumanOpinion.org - a new drupal based site
from Computerminds

suit4’s picture

there are some ways to do this, actually I don't know, if drupal
itself has a it's own way to do this.

First:
Drupal is not absolutely translatable. Depending on your project, there might be some issues, that can only fixed by modifying module code.

But here are some ideas:
1)
did you try i18n_variables in settings.php? (you have to put them in there for yourself)
I don't know, but this might work for setting a default language, but it works for at least for some other vars (http://drupal.org/node/83514)

2)
build a redirector based on the language:

// put this in your template.php

function switch_lang_on_domain() {
    global $domain_lang_defaults;
    // remove port number from host name. if present
    $server_name = str_replace(":" . $_SERVER["SERVER_PORT"], "", $_SERVER["HTTP_HOST"]);
    // pairs of domain and language
    if (isset ($domain_lang_defaults[$server_name]) && $is_front) {
        drupal_goto(i18n_path('', $domain_lang_defaults[$server_name]) . '/');
    }
}

Hint: $is_front should be filled with TRUE or FALSE, I think, drupal sets this automatically, if you are on the front page.
This is to prevent an automatic domain switch on each page reload.

// put this in your page.tpl.php

// do a switch for domains
global $domain_lang_defaults;
$domain_lang_defaults = array(
  'www.site.com' => 'en',
  'www.site.ru' => 'ru',
  'www.site.jp' => 'jp',
);
switch_lang_on_domain();

Go to your frontpage from site.jp. You should end up in site.jp/jp, where you should find the translation of the frontpage.

3)
use mod_rewrite in .htaccess

Anything usefull for you?

alqvimia’s picture

Hi,

Checking the code I've find the solution and I hope it could help other people too. (for drupal 5.x)

in the settings.php file (i.e sites/www.site.ru) I put the following code:

$conf['i18n_languages'] = array('site_default'=>'en',
'name'=> array('es'=>'Spanish' , 'ca'=>'Catalan' , 'en'=>'English'),
'rtl'=>array('es'=>'es','ca'=>'ca','en'=>'en'),
'native'=>array('es'=>'Español','ca'=>'Català','en'=>'English'),
'enabled'=>array('es'=>'es','ca'=>'ca','en'=>'en'));

The 'name" array set the languages names
The 'enabled' array set the enabled languages

Finally set default language on the 'site_default' variable in the 'i18n_languages' array.
It's important to build the whole array as it won't work if you don't write it so.

Regards