It was agreed that it's a bad practice to use flags for language icons.

I recommend against flag icons:
1. From a usability point of view, many languages reside in different countries
2. From an SEO Point of view, textual language links are better.

Textual links are much better.

The following changes are needed in i18n.module:

1. There should be an i18n setting option to hide the language icons, and only use the language name in the link. Preferably - use the translated language name, according to the current language.

2. Language name, inside the textual link, should be translated using t().

Until such a setting option exists, here is the code needed in order to hide the language icons in template.php in Drupal 4.7 and translate the language name in the language link. This was tested on my Jewish Clipart site, where you can see a demo.

Override the themable function theme_i18n_link(), defined in the i18n module.
To override it, add the following code to your template's template.php file.


function phptemplate_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 .= l(t($text), $target, $attributes, NULL, NULL, FALSE, TRUE);
  $output .= '</span>';
  return $output;
}

Amnon
-
Drupal Focused Search Engine | Drupal Israel | Web Hosting Strategies
Personal: Hitech Dolphin: Regain Simple Joy :)

CommentFileSizeAuthor
#3 i18n_noflags.patch1.97 KBrssaddict

Comments

alex_b’s picture

+1 for languages as text.

Just to add some poster cases: Spanish flag: Spanish spoken throughout most of Latin America, Spain itself with bask, catalan etc. multilingual. English, German, Quechua (which flag?)...

rssaddict’s picture

It would be fairly easy to make this an option on the settings page:

// Language switcher format
  $form['i18n_format'] = array(
    '#type' => 'radios',
    '#title' => t('Display language icons?'),
    '#default_value' => variable_get('i18n_format', 'text'),
    '#options' => array(
      'text' => t('Language Only'),
      'textandicon' => t('Language Plus Icon'),
      'icon' => t('Icon Only'))
  );

and change the theme_i18n_link function to take account of this:

function theme_i18n_link($text, $target, $lang, $query= NULL, $fragment = NULL){
  $output = '<span class="i18n-link">';
  $attributes = ($lang == i18n_get_lang()) ? array('class' => 'active') : NULL;
  switch(variable_get('i18n_format', 'text')) {
  case 'text':
    $output .= l($text, $target, $attributes, $query, $fragment, FALSE, TRUE);
    break;
  case 'textandicon':
    $output .= l(theme('i18n_language_icon', $lang), $target, $attributes, $query, $fragment, FALSE, TRUE);
    $output .= "&nbsp;";
    $output .= l($text, $target, $attributes, $query, $fragment, FALSE, TRUE);
    break;
  case 'icon':
    $output .= l(theme('i18n_language_icon', $lang), $target, $attributes, $query, $fragment, FALSE, TRUE);
    break;
  }
  $output .= '</span>';
  return $output;
}

So it would be up to the site admin to decide which format was preferred for the language switcher.

rssaddict’s picture

StatusFileSize
new1.97 KB

Here is a patch for 5.0 with the code I posted above. The default setting is text-only language links, and the language icon fieldset has been changed to collapsed by default.

rssaddict’s picture

Status: Patch (to be ported) » Needs review
forgestik’s picture

Sorry to bother you guys with such a simple question, but I just wanted to know. What do I need to do with this patch file exactly? I don't quite understand the + and - (preceeding each line).

Thanks

davemybes’s picture

Hi again :)

Check out this page: http://drupal.org/node/60108 and maybe this one as well: http://drupal.org/diffandpatch. The - means that line has been deleted and the + means that line has been added. Position of these lines is critical, so pay attention to surrounding code if you intend to apply the patch manually (i.e. copy and paste the changes).

forgestik’s picture

Hey (oh joy, my private Angel comming to my rescue once again ;-)

Look. I managed to get gnuwin32 to work. I planned to use it this way :

(from a cmd prompt under windows os)

patch -p0 < "c:\Inetpub\wwwroot\mysite\modules\i18n\i18n_noflags.patch"

This statement is getting recognize, the code runs, but gnuwin32 seems to complain about something.. Any thought? (kidding..)

Here's the error message returned by gnu : Can't find the file to patch at input line 5. Perhaps you used the wrong -p or --strip option? The text leading up to this was :

|-------------------------------
|Index : i18n.module
|==============
|--- i18n.module (revision 1)
|+++ i18n.module (working copy)
|-------------------------------
File to patch: _

I tried various things, such as running the patch somewhere else with only the patch file and the i18n.module file in one folder, but nothing would do. Gnu doesn't like me very much :(

Thanks a lot once again.
Charles

davemybes’s picture

I haven't use the gnuwin32 tools, so I'm not sure how they work exactly. I personally use UnxUtils and haven't had any problems, unless the patch is not done right.

Instead of a patch for this feature, I would recommend using the template.php code in the original post. This will save you having to redo the patch when i18n gets updated.

gagarine’s picture

Ok flags is not a good option but in my case, I use the flags system to put icons (with the language code for exempale "fr" for français). This is a image but i put the language name in the "alt" attribut.

A them language switcher fonction where you can enabled (or disabled) what you want (text,language code, traduction, flags icons, ...) is better, no?

botum’s picture

I'd like to add, that as I see it, the language name should not be translated in order to be understanded by "that" language reader in the case he needs it.

If I speak spanish and landed on an english page, I'd recognize Español rather than Spanish to get to my lang.

pkej’s picture

I'd like to add +1 as well.

Also, I think a drop down selection box option would be nice, since a list of languages sometimes doesn't vibe with the design of the site. A small globe icon in front of the box would probably give a good hint, then supply the list of languages as links in the head, including, of course, the correct lang= and title= tags.

Coupled with browser negotiation of language this would be a fairly straightforward way for many sites.

jose reyero’s picture

Status: Needs review » Closed (won't fix)

This has been addressed in newer versions (5.x...)
No new features for 4.7 branch.

phifesoul74’s picture

How could i mod this snippet code to add .last and first .class to the menu list

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 .= l(t($text), $target, $attributes, NULL, NULL, FALSE, TRUE);
  $output .= '</span>';
  return $output;
}