function locale_css_alter

Implements hook_css_alter().

This function checks all CSS files currently added via drupal_add_css() and and checks to see if a related right to left CSS file should be included.

File

modules/locale/locale.module, line 965

Code

function locale_css_alter(&$css) {
    global $language;
    // If the current language is RTL, add the CSS file with the RTL overrides.
    if ($language->direction == LANGUAGE_RTL) {
        foreach ($css as $data => $item) {
            // Only provide RTL overrides for files.
            if ($item['type'] == 'file') {
                $rtl_path = str_replace('.css', '-rtl.css', $item['data']);
                if (file_exists($rtl_path) && !isset($css[$rtl_path])) {
                    // Replicate the same item, but with the RTL path and a little larger
                    // weight so that it appears directly after the original CSS file.
                    $item['data'] = $rtl_path;
                    $item['weight'] += 0.0001;
                    $css[$rtl_path] = $item;
                }
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.