3

I have a multilingual website (English, Arabic, and French).

I have the following code:

<?php _e('<!--:ar-->للحصول على إجابة سريعة، نرحب بمكالماتكم / و
 رسائلكم عبر البريد الإلكتروني.<!--:--><!--:en-->For A Quick Answer, We Welcome Your
 Calls / Emails.<!--:--><!--:fr-->Pour Une Réponse Rapide, Nous Attendons Vos Appels
 / E-mails.<!--:-->'); ?>

I want to custom style the Arabic part of this echo so I am trying to add a div inside the Arabic part as follows:

<?php _e('<div class="note"><!--:ar-->للحصول على إجابة سريعة، نرحب
        بمكالماتكم / و رسائلكم عبر البريد الإلكتروني 
        .<div><!--:--><!--:en-->For A Quick Answer, We Welcome Your Calls / Emails.
        <!--:--><!--:fr-->Pour Une Réponse Rapide, Nous Attendons Vos Appels /
        E-mails.<!--:-->'); ?>

However, it is affecting the English and french parts too even though i am closing the div before that the english section starts.

please help

M. A. Kishawy
  • 5,001
  • 11
  • 47
  • 72
TooFast
  • 65
  • 10
  • 2
    You are not closing the div. The end tag is missing a `/`. The solution in your answer works because you do have a `/` in there, not because it happens to contain the style inline. – Mr Lister Sep 16 '16 at 12:52
  • 1
    As an advice when mixing Right-To-Left languages with Left-To-Right ones, I found that using variables can make your life easier and your code more organized. IDEs and text editors tend to get crazy with these mixes and you won't be able to easily control the flow of the text. – M. A. Kishawy Sep 16 '16 at 13:17
  • @MrLister You do have a point here but there was also another trick to make it work via external css. I have to put the "note" div inside the part as follows to make it work:
    للحصول على إجابة سريعة، نرحب بمكالماتكم / و رسائلكم عبر البريد الإلكتروني.
    For A Quick Answer, We Welcome Your Calls / Emails.Pour Une Réponse Rapide, Nous Attendons Vos Appels / E-mails.'); ?>
    – TooFast Sep 16 '16 at 22:10

1 Answers1

1

I fixed it by using inline css instead of naming a class for the div. So the following code worked fine for me:

<div class="note"><?php _e('<!--:ar--><div style="direction:rtl;">للحصول على إجابة سريعة، نرحب بمكالماتكم / و رسائلكم عبر البريد الإلكتروني.</div><!--:--><!--:en-->For A Quick Answer, We Welcome Your Calls / Emails.<!--:--><!--:fr-->Pour Une Réponse Rapide, Nous Attendons Vos Appels / E-mails.<!--:-->'); ?></div>

the weird thing is that if I use class for the div and then edit the class in an external css then it will affect all languages.

TooFast
  • 65
  • 10
  • 1
    I guess it depends on your project, but failing to separate your CSS from HTML by using inline CSS usually tends to become messy and hard to maintain in long run. – M. A. Kishawy Sep 16 '16 at 12:46