Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm developing a website using the WPML plugin. And I would like to know which is the better option, or even the correct way to change classes or IDs between the languages.

Sample code:

<ul id="<?php _e('menu-topo'); ?>">

<ul id="<?php if ($lang = 'en') { echo "menu-topo-en"; } else { echo "menu-topo"; } ?>

I'm not sure that the _e function is supposed to be used this way so if someone could clarify this for me it would help me a lot, thanks.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

_e() will translate the text passed as a argument to the language your site is currently set up to use (if the translation exists).

Anyway, don't do that. Use it for text visible on the website, not for IDs/classes etc. To create context based css rules, simply add the WPML language ID as a body class:

add_filter('body_class', 'wpml_body_class');
function wpml_body_class($classes){
  return array_push($classes, ICL_LANGUAGE_CODE);
}

then style the elements you need to using something like:

.en .menu-top{
 ...
}

It's faster, and you keep your code easy to maintain.

share|improve this answer
    
Amazing solution my friend, thank you! –  Vitor Argos Apr 15 '11 at 20:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.