PHPJavascript

Web Development Guide – My Personal Library of Tutorials and Scripts

drupal arabic or rtl support theming

February18

Create a separate stylesheet like style-rtl.css

Then in the page.tpl file instead of <?php print $styles?> variable use the following:

<?php
$rtl_langs = array(”ar”, “fa”, “he”, “ur”, “yi”); // There are a couple or so more. Put the codes of your RTL languages here
$is_rtl = in_array ($language, $rtl_langs);
if ($is_rtl) { // Check if the language of the current page is RTL.
/* Load RTL styles instead of default ones: */
foreach($css as $media => $types){
foreach($types as $type => $files){
foreach($files as $file => $preprocess){
$element = $file;
$rtl_style = str_replace(array (’modules’, ‘.css’),array (’sites/all/modules’,'-rtl.css’),$file);
if(file_exists($rtl_style)){
unset($css[$media][$type][$file]);
$css[$media][$type][$rtl_style] = $preprocess;
}
}
}
}
print drupal_get_css($css);
}
else {
print $styles;
}
?>


posted under Drupal

Email will not be published

Website example

Your Comment:

 

2,885 spam comments
blocked by
Akismet