Community & Support

Any way to get both translated and default (english) site name on the same page?

Hi everyone!

I'm running Drupal 6.14 website in English and Russian and faced the following issue: I'd like to display $site_name both in English (default) and Russian on every page of my site but can't find the proper way to do that.

I tried the following way:
template.php
...
$vars['site_name_en'] = locale($vars['site_name'],'en');
$vars['site_name_ru'] = locale($vars['site_name'],'ru')
...

page.tpl.php
...
<area shape="rect" coords="..." href="/ru" title="<?php print $site_name_ru; ?>" alt="<?php print $site_name_ru; ?>" />
<area shape="rect" coords="..." href="/" title="<?php print $site_name_en; ?>" alt="<?php print $site_name_en; ?>" />
...

And it works for English. But as soon as I switch the language to Russian I get my site name two times in Russian.

Could anyone please give me some hint how can I get both translations of my site name on the same page? Thanks in advance for any help!

PS I've made a temporary solution, but I think there is a proper way of doing things that I need:

template.php
$vars['site_name_en'] = '_site_name_in_english_';
$vars['site_name_ru'] = '_название_сайта_на_русском_';

PPS I'm newbie to Drupal (trying to migrate all my sites from Joomla to Drupal).

Comments

What you are doing looks

What you are doing looks right.

Where does $vars['site_name'] come from? Maybe it is already translated to Russian when you call the locale function.

I'll try to explain

Hi, Bruce! Thanks for your answer!

I set up my site using this tutorial: http://drupal.org/node/275705 and added $conf['i18n_variables'] array to settings.php of my site. My default language is English and I set the name of my website (on site-information page) as e.g. "My Site". Then a switched to Russian version of my site and set the name of my website in Russian - "Мой сайт". A also set up my default home page for both versions - 'about'.

On my admin/build/translate/search page I have the following:
Text group: Built-in interface
String: My Site
Path: /

This string is translated as "Мой сайт".

Where does $vars['site_name'] come from?

It comes from global variable $site_name. A also tried to change it to:

template.php

function theme_preprocess(&vars) {
...
  $title = t(variable_get('site_name', ''));

  $vars['site_name_en'] = locale($title, 'en');
  $vars['site_name_ru'] = locale($title, 'ru');
}

But with no success. I still have both English and Russian site names on the English version of my site but double Russian site names on the Russian version of my site.

It seems that when I switch language to Russian global variable $site_name becomes "Мой сайт" and then can't be translated back to English :(. It works only for English to Russian translation but not vice versa.

nobody click here