From 3a2d9c86108d1b6baae3743926e8f7370688a2b7 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sat, 21 Jan 2017 16:12:25 +0100
Subject: [PATCH] Fix for rtl languages

---
 htdocs/core/class/translate.class.php             | 15 +++++++--------
 htdocs/core/lib/functions.lib.php                 |  2 +-
 htdocs/societe/soc.php                            |  2 +-
 .../societe/tpl/linesalesrepresentative.tpl.php   |  2 +-
 htdocs/theme/eldy/style.css.php                   |  8 ++++----
 htdocs/theme/md/style.css.php                     |  8 ++++----
 6 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index 6b596dc3aa5..4c4d1ad6e10 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -29,17 +29,16 @@
  */
 class Translate
 {
-	var $dir;                          // Directories that contains /langs subdirectory
+	public $dir;                          // Directories that contains /langs subdirectory
 
-	var $defaultlang;                  // Current language for current user
-	var $direction = 'ltr';            // Left to right or Right to left
-	var $charset_output='UTF-8';       // Codage used by "trans" method outputs
+	public $defaultlang;                  // Current language for current user
+	public $charset_output='UTF-8';       // Codage used by "trans" method outputs
 
-	var $tab_translate=array();        // Array of all translations key=>value
-	private $_tab_loaded=array();      // Array to store result after loading each language file
+	public $tab_translate=array();        // Array of all translations key=>value
+	private $_tab_loaded=array();         // Array to store result after loading each language file
 
-	var $cache_labels=array();         // Cache for labels return by getLabelFromKey method
-	var $cache_currencies=array();     // Cache to store currency symbols
+	public $cache_labels=array();         // Cache for labels return by getLabelFromKey method
+	public $cache_currencies=array();     // Cache to store currency symbols
 
 
 
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 08afbc283f4..eb69364596f 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -2504,7 +2504,7 @@ function img_edit($titlealt = 'default', $float = 0, $other = '')
 
 	if ($titlealt == 'default') $titlealt = $langs->trans('Modify');
 
-	return img_picto($titlealt, 'edit.png', ($float ? 'style="float: right"' : $other));
+	return img_picto($titlealt, 'edit.png', ($float ? 'style="float: '.($langs->tab_translate["DIRECTION"] == 'rtl'?'left':'right').'"' : $other));
 }
 
 /**
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 020d0aad63f..80db7aef081 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -2239,7 +2239,7 @@ else
             print '<table width="100%" class="nobordernopadding"><tr><td>';
             print $langs->trans('IncotermLabel');
             print '<td><td align="right">';
-            if ($user->rights->societe->creer) print '<a href="'.DOL_URL_ROOT.'/societe/soc.php?socid='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
+            if ($user->rights->societe->creer) print '<a href="'.DOL_URL_ROOT.'/societe/soc.php?socid='.$object->id.'&action=editincoterm">'.img_edit('',1).'</a>';
             else print '&nbsp;';
             print '</td></tr></table>';
             print '</td>';
diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php
index fe2add787c4..0c3dd0656b8 100644
--- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php
+++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php
@@ -5,7 +5,7 @@
         print $langs->trans('SalesRepresentatives');
         print '<td><td align="right">';
         if ($user->rights->societe->creer && $user->rights->societe->client->voir)
-        print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$object->id.'">'.img_edit().'</a>';
+        print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$object->id.'">'.img_edit('',1).'</a>';
         else
         print '&nbsp;';
         print '</td></tr></table>';
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 5e354590eb8..3cce27c4a2a 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -1244,10 +1244,10 @@ div.menu_titre {
 .mainmenuaspan
 {
 <?php if ($disableimages) { ?>
-	padding-left: 4px;
-	padding-right: 2px;
+	padding-<?php print $left; ?>: 4px;
+	padding-<?php print $right; ?>: 2px;
 <?php } else { ?>
-	padding-right: 4px;
+	padding-<?php print $right; ?>: 4px;
 <?php } ?>
 }
 
@@ -2056,7 +2056,7 @@ a.tabTitle {
 	font-family: <?php print $fontlist ?>;
 	font-weight: normal !important;
     padding: 4px 6px 2px 0px;
-    margin-right: 10px;
+    margin-<?php print $right; ?>: 10px;
     text-decoration: none;
     white-space: nowrap;
 }
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 2698b258e65..4ab240af4d6 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -1254,10 +1254,10 @@ div.menu_titre {
 .mainmenuaspan
 {
 <?php if ($disableimages) { ?>
-	padding-left: 4px;
-	padding-right: 2px;
+	padding-<?php print $left; ?>: 4px;
+	padding-<?php print $right; ?>: 2px;
 <?php } else { ?>
-	padding-right: 4px;
+	padding-<?php print $right; ?>: 4px;
 <?php } ?>
 }
 
@@ -2042,7 +2042,7 @@ a.tabTitle {
 /*    background: #657090;
     color: white;*/
     color:rgba(0,0,0,.5);
-    margin-right:10px;
+    margin-<?php print $right; ?>: 10px;
     text-shadow:1px 1px 1px #ffffff;
 	font-family: <?php print $fontlist ?>;
 	font-weight: normal;
-- 
GitLab