Where in drupal themes files I could apply the following blueprint code:

if ($language->language == 'ar'){
// Do something to change the included style.css to be style_rtl.css

Does it template.php or html.tpl.php? and How to implement the comment in the code above?

I use Drupal 7


You want to put it in template.php and probably want something like this:

function hook_css_alter(&$css) {
  global $language, $theme_path;
  if ($language->language == 'ar'){
    unset($css[$theme_path . '/css/style.css']);
    drupal_add_css($theme_path . '/css/style_rtl.css', array('group' => CSS_THEME, 'every_page' => TRUE));

I think there is something in the Domain Access project regarding theme settings, if you are using that suite of modules.

  • Your solution as it is, does not work. However, I had to replace the hook with the theme name to make it run. i.e my_theme_css_alter() Could you please tell me why does not it work with hook?
    – SaidbakR
    Jun 16 '14 at 11:57
  • 1
    Because you create a hook implementation in Drupal by replacing hook with your module or theme name. I've edited the answer to reflect this.
    – jamix
    Jun 16 '14 at 12:57

Another way to do this would be using prefixing your CSS classes/id's with .i18n-en and .i18n-es (for English and Spanish respectively). Here's an example:

.i18n-en .myclass {
    color: #ff0000;

.i18n-es .myclass {
    color: #336699;

You'll see this in the <body> tag.

You can also make use of hook_css_alter. Check this page for the official documentation and some examples.

  • Your solution is good but in the end will lead to very big CSS file that affect website performance (downloading time)
    – SaidbakR
    Jun 16 '14 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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