Jump to content

Language ltr & rtl


Recommended Posts

hi! i have a question, i have multi language site and i need some way to change the direction when user language is hebrew from right to left - left to right, i try this 

  • foreach($languages as $language) {
  • if($language->title == "hebrew"){
  • echo 'style="direction:RTL"';
  • }
  • i read a lot of post but i dind find some solution.
  • thank you!
Link to comment
Share on other sites

hi Rjay, i am trying to echo style="direction:RTL" inside body tag if the user language is hebrew

<body <?php foreach($languages as $language) { if($language->title == "hebrew"){ echo 'style="direction:RTL"';}?>> something like this? i cant make it work.

Link to comment
Share on other sites

I am not really sure what you have going on, but your current code does not make any sense to me. Can you show me an example of the site? What are you looping through? Pages?

There are better ways I think you could do this, but here it what you are trying to do should look like

foreach($languages as $language) { // loop through $languages
   if($language->title == 'hebrew') {  // Now that you have $language, check if its title is == hebrew
      echo "<body style='direction:rtl;'>"; // if it is, assign it a style
      } else {
      echo "<body>";  // if not, echo body with no style. 
Edited by RJay
Link to comment
Share on other sites

Glad you got it working. I should have re-read your post better paying attention to "user". I also should have realized I was in the Multi-Language Support section. I am glad apeisa picked up my slack and pointed you in the right direction.

Link to comment
Share on other sites

I recently had to deal with this too. I ended up creating a checkbox field called "rtl" and added it to the "language" template. Now you can easily add a class or hardcode like:

<?php if ($user->language->rtl) echo "style='direction:rtl;'"; ?>

If you add another language which needs RTL you can just check the "rtl" field and don't have to change the code.

  • Like 6
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...