RTL languages (Arabic and Hebrew) do not right align

If one takes the below RSS feed for news on Drupal (in Arabic) and adds it to via the Feeds module:

http://news.google.com/news?pz=1&hl=ar&q=%D8%AF%D8%B1%D9%88%D8%A8%D8%A7%...

one will notice that the text is left aligned while it should be right aligned.

Comments

haisam’s picture

One feed may have a mixture of RTL and LTR scripts so the display of the text should not be global to the Feed but specific to the feed item.

haisam’s picture

Here's my rough workaround.

Replace ..../managingnews-1.0-beta5/profiles/managingnews/themes/jake/templates/mn-feeditem.tpl.php with what is below and the RTL languages' title and description will be right aligned. This worked for Arabic, Hebrew and Persian.

  <?php $dirt = preg_match('/[\x{600}-\x{6FF}]|[\x{590}-\x{05ff}]/u', jake_views_render_field($fields['title'])); ?>
  <?php $dirc = preg_match('/[\x{600}-\x{6FF}]|[\x{590}-\x{05ff}]/u', jake_views_render_field($fields['description'])); ?>
  
  <div class='feeditem clear-block'>
  
  <div class='feeditem-meta clear-block'>
    <?php print jake_views_render_field($fields['timestamp_1']) ?>
    <?php print jake_views_render_field($fields['title_1']) ?>
  </div>

  <h2 class='feeditem-title clear-block'  dir="<?php print $dirt ? "rtl" : "ltr"; ?>">
    <?php print jake_views_render_field($fields['title']) ?>
  </h2>

  
  <div class='feeditem-content prose clear-block' dir="<?php print $dirc ? "rtl" : "ltr"; ?>">
    <?php print jake_views_render_field($fields['description']) ?>
  </div>

  <div class='feeditem-labels clear-block'>
    <?php print jake_views_render_field($fields['data_node_list']) ?>
  </div>

  <div class='feeditem-links clear-block'>
    <?php print jake_views_render_field($fields['mn_share_link']) ?>
    <?php print jake_views_render_field($fields['data_node_add_remove']) ?>
  </div>

  <div class='feeditem-terms clear-block'>
     <?php print jake_views_render_field($fields['tid']) ?>
  </div>

</div>
Will White’s picture

Version: 6.x-1.0-beta5 » 6.x-1.x-dev
Category: bug » feature

The fix for this is clearly not straightforward as language direction can vary by feed and even by item. I'm not aware if any feed formats that have widely used elements that indicate text direction. If one does exist, please point me in the right direction.

Otherwise, the only approach I can think of is to provide a "Text direction" checkbox on the feed node form so site admins could make a decision on at least the feed level about what reading direction to use. I'm not sure this is something that should be supported in the main Managing News distro, but I could imagine a separate contributed module being effective here.