Using Drupal 4.7. Installed cvs version of Internationalization Module. Enabled locale, i18n and translation modules. Enabled Language Switcher block.

Problem: I can't seem to get language dependent variables working. I read in the INSTALL.txt

The list of variables to be made language dependent must be defined in the config file:
  
    $conf['i18n_variables'] = array(
        // Site configuration
        'site_name',
        'site_slogan',
        'site_mission',
        'site_footer',
        'anonymous'
);

These are only the suggested ones, but you can add as many Drupal variables as you want to the array.
    
You need to redefine these variables for the first time for every language, as previous values are lost and they return to defaults -they will be back if you disable i18n-

I am unsure about how to do this. Do I need to redefine these variables for EACH language in the config file? If so how do I specify which language to associate the defined variable with? For example if I add the following to the config file to define the site name in English:

    $conf['i18n_variables'] = array(
        'site_name' => 'my site name in English',
);

Then what do I need to add to the config file to specify the site name in Russian and Latvian?

Comments

Marc Bijl’s picture

Add this code at the end of the file /sites/default/settings.php just before the final ?>

$conf['i18n_variables'] = array(
        // Site configuration
        'site_name',
        'site_slogan',
        'site_mission',
        'site_footer',
        'anonymous'
);

To define site names in different languages, e.g. language A and B:
- Be sure you got both language enabled through localization (Administer > Localization).
- Go to www.example.com/language-prefix-A/admin/settings
- Define site name in language A at the general settings, and save these settings
- Go to www.example.com/language-prefix-B/admin/settings
- Define site name in language B at the general settings, and save these settings

This should do the trick. The thing here is that one need to administer and save in different languages to set the values of i18n variables.

If the code above does not work, you can also try with $i18n_variables = array( ... );. That's what I did and works pretty good (cannot remember if I had trouble with the code above).

To use translated menu items, one should have i18n menu module installed, and translate the strings (menu items) through localization. However, I'm still struggling to get them working, that is, having only one menu with the items pointing to the right nodes, depending on the interface language.

Success!
Marc

___________________
discover new oceans
lose sight of the shore

lisa’s picture

Hi Marc,
First, thanks for giving such a clear explanation. Unfortunately, I still can't get the language dependent variables to work.

I added the code to the settings.php just before the final ?>

$conf['i18n_variables'] = array(
        // Site configuration
        'site_name',
        'site_slogan',
        'site_mission',
        'site_footer',
        'anonymous'
);

I made sure I had all languages enabled through localization (in my case, Latvian, English and Russian).

I went to mysite/lv/admin/settings
and changed the site name and saved the settings.

Then I went to mysite/en/admin/settings
and changed the site name and saved the settings.

Then I went to mysite/ru/admin/settings
and changed the site name and saved the settings.

BUT when I go to my home page and click on the various languages (using the flags in the Translations block) the site names are all in Russian. That is admin->settings seems to be overwriting and only keeping whatever setting I saved last.

I tried your suggestion of changing the code above replacing

$conf['i18n_variables']

with

$i18n_variables

but it did not help. I also tried going back to admin->settings and resetting the defaults for EACH of the languages and then tried changing and saving the site names for each of the languages. That didn't help either.

All I can think to try now is disabling i18n, translation and and locale modules and then re-enabling. Or perhaps uninstalling and then reinstalling Internationalization module.

Any other suggestions would be greatly appreciated.

Thanks

Marc Bijl’s picture

What I would try, is check what has been saved - and what not. Please, look again at the pages:

- mysite/lv/admin/settings
- mysite/en/admin/settings
- mysite/ru/admin/settings

Did Drupal save the different site names, or are they all still the same? If Drupal did not save the different site names, unfortunately I don't know where things went wrong. The steps you described seem to be the right ones, AFAICS...

However, if Drupal did save the different file names, it might be a cahing problem. You could disable caching at your settings page, or try a "delete from cache;" in the database area (I use dba module). Another possibility is that the browser's cache needs to be cleaned.

If then things still go wrong, you could try and use the address bar in the browser instead of the block to switch languages; just change the language prefix and see what happens.

That's all I can think of right now...

___________________
discover new oceans
lose sight of the shore

lisa’s picture

Thanks again for all your help - I do appreciate it. I tried all of your suggestions and THEN found my ridiculous mistake. :)

First I used the address bar in the browser to go to:
mysite/lv/admin/settings
I typed in the site name in Latvian and hit 'save configuration'.

Then I used the address bar to switch to mysite/en/admin/settings
I typed in the site name in English and hit 'save configuration'.

Then I used the address bar to go back to mysite/lv/admin/settings to check what Drupal had saved. Under general settings for Latvian it showed the site name in English - i.e. it showed the last setting I saved. It seemed that Drupal was only keeping one setting for all languages.

Under admin->settings I checked that page cache was disabled for all languages.

I also cleared the cache in my browser (Firefox).

I accessed my mySQL database via Term window and cleared the cache table using:
delete from cache;

But Drupal was still NOT saving the different site names.

THEN I went back to settings.php one more time and found a */ at the bottom of the file that seemed out of place. I moved it and saved the file. Then went back and entered and saved a site name for each language under admin->settings.
And voila - I have language dependent variables that work!

Shoot me now! :)

It seems the misplaced */ was causing all the language dependent variables to be commented out.

There are a number of such comment symbols in settings.php that confuse a newbie like me:

/**
*
*/
#
//

Here is an explanation that may help others:
http://www.php.net/manual/en/language.basic-syntax.comments.php

Thanks again for your help.

lisa’s picture

BTW - I also noticed that the settings.php that comes with Drupal 4.7 does not have a ?> at the end of the file.

Is this intentional?

Marc Bijl’s picture

As far as I know, since it starts with <?php it should end with ?>...

___________________
discover new oceans
lose sight of the shore

Marc Bijl’s picture

POOOFFF!!!   ;-)

Good to read it's all fine now.

___________________
discover new oceans
lose sight of the shore

Jürgen Depicker’s picture

That seemed to fix it for me too: no superfluous comment signs in my settings.php: just missing ?> at the end, and maybe a ',' too much behind the last variable in the array?
Anyhow, all working now!

mik77’s picture

As you can read under Drupal Coding Standards:

Note that as of Drupal 4.7, the ?> at the end of code files is purposely omitted. This includes for module and include files.

Follow the link above and look for the PHP Code Tags heading to find out about the reasons.