Jump to content

Dual language support: right to left, and left to right


Recommended Posts

Thanks. It is useful.

 

But the main challenge I have is how to approach the web site design when it could be used by R2L or by L2R users.

Should I duplicated the pages? this will cause maintenance to be painful.

 

Should I have a parameter which will indicate R2L or L2R and have many IF with in the pages?

This will make the code less readable.

 

Is there a recommended solution?

Thanks. It is useful.

 

But the main challenge I have is how to approach the web site design when it could be used by R2L or by L2R users.

Should I duplicated the pages? this will cause maintenance to be painful.

 

Should I have a parameter which will indicate R2L or L2R and have many IF with in the pages?

This will make the code less readable.

 

Is there a recommended solution?

 

If you generate the code with PHP then you can just set the dir attribute.

I would prefer to use CSS for this, as it makes the code a little more robust and easy to maintain. CSS has a property for this called the "direction" property which has three possible values: ltr (left to right, default), rtl (right to left) and inherit meaning it inherits the direction property from its parent element. As ManiacDan stated, a class for this can be made and be assigned to any text that you want this to affect. There are several ways to implement the ltr, rtl change as well.

I would prefer to use CSS for this, as it makes the code a little more robust and easy to maintain. CSS has a property for this called the "direction" property which has three possible values: ltr (left to right, default), rtl (right to left) and inherit meaning it inherits the direction property from its parent element. As ManiacDan stated, a class for this can be made and be assigned to any text that you want this to affect. There are several ways to implement the ltr, rtl change as well.

 

Thanks. I like the idea, and I will try it.

 

What about the text itself?

For example, on  a certain page I will need to display a content/ For example, write a "Hello" in case of L2R, or the same word in a different language R2L.

Should I have many "if" statements in the code, so the server will send the right word according to the $direction variable?

O

 

Without seeing the logic in your code, it would be impossible to tell you exactly how you should implement this into your code. The method you provided could work, although it seems tedious to write many if statements. Again, without seeing how you are setting up the different language texts, it's hard to say. However something along the lines of determining what language the text is, and wrapping it in an element with the direction class dynamically is most likely what I would do. You can also detect the strings encoding using an mb function, mb_detect_encoding and act accordingly.

Just give each text element the directional class, and at the top of your page have a very small in-line stylesheet that conditionally defines it as left to right, or right to left. Personally I would only define it if it's right to left.

What you need to do is wrap EVERY word in a "translate" function.  For every piece of text on your website, instead of echoing it directly, echo tl("Hello!");  Then make a translation file that maps "Hello!" To "Hola!" And "Bonjour!"  tr() will echo the proper one based on your language.

What you need to do is wrap EVERY word in a "translate" function.  For every piece of text on your website, instead of echoing it directly, echo tl("Hello!");  Then make a translation file that maps "Hello!" To "Hola!" And "Bonjour!"  tr() will echo the proper one based on your language.

 

Good idea, but why to do in on word basis? why not sentence?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.