1

I have to create a menu that includes items in a variety of languages including Arabic and Farsi.

Something like this:

-LTR item
-LTR item
 RTL item - 
-LTR item
 RTL item -

Is there a way to add the dir='rtl' to specific menu items?

And more importantly, is there a way for me to make this accessible to non-technical users that will be maintaining the site after I have created it?

The site is being built in Drupal 8

Ideas?

1

Maybe starting from https://www.drupal.org/project/link_attributes and contributing a dir attribute patch (this way you have a UI for non tech users that will maintain the site)

1

You can use hook_preprocess_HOOK

/**
 * Implements hook_preprocess_HOOK().
 */
function hook_preprocess_menu(&$variables) {
  $variables['attributes']['class'][] = 'clearfix';
  if($variables['menu_name'] =='main'){
    foreach($variables['items'] as $item){
      if($item['title'] =='Home'){
        $item['attributes']['dir']='rtl';
      }
    }
  }
}

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.