Using Drupal 4.7.2 and cvs version of Internationalization (installed cvs before 4.7 version was released).

Under admin->localization it says to add languages using the English name. But if I do that then then the Translations block displays flags and English name of language.

1. Is it ok to enter the language name in its native form (Cyrillic) under admin->localization?

2. If not, how can I get Translations block to display language names in native form?

3. How do I get Translation block to display only flags?

I've seen some solutions for 4.6 but none that work for 4.7. Thanks.

Comments

lisa’s picture

Title: i18n translation block - display language names in native form or flags only » i18n translation block - how to display language names in native form?

Ok. I figured out #3 - how to display flags only. Here is what I did:

I found this bit of code in the i18n.inc file that came with i18n (Internationalization) module.

/**
 * Produces a language link with the right flag
 */
function theme_i18n_link($text, $target, $lang, $separator=' '){
  $output = '<span class="i18n-link">';
  $attributes = ($lang == i18n_get_lang()) ? array('class' => 'active') : NULL;
  $output .= l(theme('i18n_language_icon', $lang), $target, $attributes, NULL, NULL, FALSE, TRUE);
  $output .= $separator;
  $output .= l($text, $target, $attributes, NULL, NULL, FALSE, TRUE);
  $output .= '</span>';
  return $output;
}

I added this bit of code to the template.php file that came with my theme (box_grey, a phptemplate theme)

function phptemplate_i18n_link($text, $target, $lang, $separator='&nbsp;'){
  $output = '<span class="i18n-link">';
  $attributes = ($lang == i18n_get_lang()) ? array('class' => 'active') : NULL;
  $output .= l(theme('i18n_language_icon', $lang), $target, $attributes, NULL, NULL, FALSE, TRUE);
  $output .= $separator;
#  $output .= l($text, $target, $attributes, NULL, NULL, FALSE, TRUE);
  $output .= '</span>';
  return $output;
}

Note: It's the same code from i18n.inc. I simply changed 'theme' to 'phptemplate' in the first line and commented out (#) one line - the one that produces the language name.

I would still like to know how to display languages in native form in the Translations block. Can anyone help?

jose reyero’s picture

You just need to enter languages -in locale module- in whatever form you want them to be shown.
So if you want native names, just enter native names.

About the 'only flags' option, yes, that's it. It is a themeable function. I think I'll add this somewhere into the documentation, thanx.

lisa’s picture

Thanks, Jose. When I reread your i18n INSTALL.txt file I saw the note that

You have to define languages using the native name, also in the locale module. This is the name that will show up in the block.

I missed that the first time through, and had been hesitant to try it since the admin->locale page instructs you to enter the English name. I went there and changed them to native names and they seem to work fine.

Thanks for a great module.

jose reyero’s picture

Status: Active » Closed (fixed)
4v4l0n42’s picture

Hi,
i've got the snippet to work, but there is something REALLY strange that I can't explain.

If I use firefox i can see the block with the two flags for Italian and English:
http://mediagrouptv.com/trendtv/en/my-events/intrapresae-guggenheim

If I use Safari or IE the block is not there, though the HTML code shows it's supposed to be there! o_O

Help!

4v4l0n42’s picture

OK, solved. It was a problem of CSS and overlaying divs. ;)

Niaina’s picture

Title: i18n translation block - how to display language names in native form? » How do I get Translation block to display only flags WITH DRUPAL 6?
Version: master » 6.x-1.1

This tuto is very interresting but could you say how to get a translation block to display only flags, BUT IN DRUPAL 6 ?

Please, help me!

thanks.