View Full Version : [HOW TO - vB4] Making stuff right-to-left (RTL) compatible - example: images

30 Oct 2009, 22:24
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:
<img src="images/yourfolder/arrow-{vb:stylevar right}.png" alt="" />...and that's why I thought this little gem might be of use to some.

19 Dec 2009, 18:41
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:

<img style="float:{vb:stylevar right}" src="arrow-{vb:stylevar right}.png" /> <span style="float:{vb:stylevar right}">sometext</span>
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..


31 Dec 2009, 05:10
@Felix: That's already done globally inside HTML tag: dir="rtl"

31 Dec 2009, 10:32
@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..:o
THX for making me rethink!!!!