Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
[HOW TO - vB4] Making stuff right-to-left (RTL) compatible - example: images
cellarius
Join Date: Aug 2005
Posts: 1,973

Augsburg, Germany
by cellarius cellarius is offline 30 Oct 2009

The credit for this really goes to Freddie at vbulletin.com, and I readily admit that I have blatantly stolen this little valuable bit of information from one of his comments in the alpha bugtracker. Thanks to Freddie for letting me crib off

What's this good for?

As you probably all know, vBulletin can be used with languages that are read in right to left direction. If you need to provide for this anywhere in your own styles and templates, you can use the style variable {vb:stylevar right} which can be used in css and template files. If the text orientation is standart left-to-right, it's value is "left", if its right-to-left, it's value is "right".

Example: Image with orientation

Say, you have an image or icon that in any way represents a direction, it's possible that the orientation of that image has to change along with the reading direction. An existing example would be the left or right arrow in pagination, for previous and next page. It's good practice to provide for this.

How to do it?

Assume you have an image file, for example: arrow.png

In a first step, add the current direction orientation to the file, using either left and right as suffix. We end up with an image file: arrow-left.png

Now flip the image and change the prefix accordingly. Now we have a second image file, called: arrow-right.png

In your template reference this image as follows:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

...and that's why I thought this little gem might be of use to some.

Last edited by cellarius; 30 Oct 2009 at 21:49..
Views: 3567
Reply With Quote
Comments
  #2  
Old 19 Dec 2009, 17:41
derfelix derfelix is offline
 
Join Date: Dec 2001
very nice, thx alot..
One question..
If in ltr the image comes before the text
(example : sometext <img src="arrow-left.png" />)
in rtl wouldnt you want to have the image on the other side of the text?
(example : <img src="arrow-right.png" /> sometext)

does that meen you have to float every single bit of text?
for the example above the code would be:

<div>
<img style="float:{vb:stylevar right}" src="arrow-{vb:stylevar right}.png" /> <span style="float:{vb:stylevar right}">sometext</span>
</div>
I meen do you have to float the text also.. because otherwise the spacing between image and arrow would become huge..
Or is there a better solution? because that would meen that ever bit of text has to be floated, giving potential clearing errors on numerus occasions..

Felix
Reply With Quote
  #3  
Old 31 Dec 2009, 04:10
coffee's Avatar
coffee coffee is offline
 
Join Date: Oct 2002
@Felix: That's already done globally inside HTML tag: dir="rtl"
__________________
-
Reply With Quote
  #4  
Old 31 Dec 2009, 09:32
derfelix derfelix is offline
 
Join Date: Dec 2001
Originally Posted by coffee View Post
@Felix: That's already done globally inside HTML tag: dir="rtl"
Yes you are right...!!!!
What made me think it didnt work was the test on vbulletin.com forums...

But i didnt take into consideration that in translation the phrases get switched around!!! and in their demo they use english!!!
I didnt think of that..
THX for making me rethink!!!!

F.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


New To Site? Need Help?

All times are GMT. The time now is 05:41.

Layout Options | Width: Wide Color: