Hello,
I found your website on a WordPress forum. Currently I am rebuilding a website in wordpress that is in English and Farsi. I am using the Qtranslate and a theme called suffusion which supports RTL. The theme does come a rtl.css which moves everything to the right which is great. The problem I am having is switching from my LTR Style Sheet to RTL stylesheet when the language is switched. If you could be of any assistance on this it would be greatly appreciated.
Thank You – Chris
First let’s assume that your language is xy_XY (replace with your real language like fr_FR, fa_IR, etc…)
The direction for the language is declared on a php file located on the same directory where your languages files reside, actually the folder /X/wp-content/languages/
(where X is the path to the WP installation).
For each language there should be 3 files:
- xy_XY.mo [required]: compressed language file, all text strings are pulled from this file
- xy_XY.po [not required]: Ignore it unless you want to modify the default WP text strings
- xy_XY.php [not required]: Used for declaring the text direction for the xy_XY language, if not present LTR is assumed
Don’t be surprised if you don’t find the php file xy_XY.php, your description suggests that it’s missing, so create it and add this line of code:
<?php $text_direction = "rtl"; ?>
This should fix your error and the direction will be set to RTL for your RTL language.
Thank you so much! This worked
How about if we want to add a conditional statement based on custom field value for example value called switch with key as RTL to switch to RTL for a certain post?
So does this mean I can have both english and arabic posts in my blog and the arabic posts will switch to RTL automatically based on the custom field?
Yes, this is right, assuming that your theme is optimized for both RTL and LTR.
Nabil, I am writing both in English and Urdu (RTL) in my blog. But language folder is missing from my WordPress install. How do I set my language preferences?
A reply will be highly appreciated.
Thanks
Irfan
The languages directory is not available on the default installation (English), you can create it manually and add your languages .po and .mo files, then you can change the language of your wordpress installation by modifying the constant WP_LANG on wp-config.php like this:
References:
WordPress in your language
Installing WordPress in your language
Thanks a ton Nabeel for a quick reply.
When I created the folders in my language, and defined the language in config.php; the admin panel also got translated in the language I set.
Is there a way I can use the admin panel in English while using the language of my choice for posts?
Thanks.
Just found a work around. I installed a plugin called ‘Admin in English’, which solved my problem. Thanks anyways.
Hi Nabil,
Thank you for providing support to us misrepresented rtl folks.
I am working with farsi and english and sometimes there is a lot more that text-direction needed for farsi pages. I made different CSS files for each language. I was wondering about the best way to load them up. I have tried loading each css based on current language, which is determined by a qtranslate function:
My code is not working but I’m wondering if this is a good practice.
Is this function being fired off before everything else? If you think this should work, this is the code I have in the header so far:
I tried manual link, or using my themes
bloginfo('stylesheet_url')
but nothing shows to this point.I appreciate any suggestion.
http://www.manArtGallery.com
I face the same issue too because I write in Arabic (RTL), what I do while writing a new theme is:
style.css
for direction neutral CSS properties like colors, widths, fonts, etc…style-rtl.css
andstyle-ltr.css
for direction specific CSS declarations likepadding-right
,margin-left
, borders, etc, the last two files will have the exact number of lines but each property will be defined differently in each file.Al salam Alaikum Nabil,
I spent almost half a day searching for this solutions. Thanks a million times for this tip. However minor correction the
xx_XY.php
needs to be save under/wp-includes/languages/
instead of/wp-content/languages
folder.I wrote the following condition in my themes header file to output the content in the RTL direction:
I used a nice plugin name RTLer http://wordpress.org/extend/plugins/rtler/ to generate rtl.css for any theme.
I also used [qTranslate] and [Codestyling Localization] plugins to aid in the translation and localization of themes and other plugins.
Regards,
MAD
Wa alaikoum assalam
It’s a bit late to say that – But never touch the folder
wp-includes
Anyways, I checked again and I confirm that the languages folder resides in
wp-content
.I had the same problem and it’s NOW FIXED! THANK U VERY MUCH!!! 🙂
Hi Nabil
Thank you for the clear and concise text above.
However, I followed your steps but still couldn’t get my Arabic site to display rtl.(I am using qtranslate)
what could be wrong?
I have been struggling all day with this problem! thank you soooooo much for saving my life!
Hi Nabil,
I have a Theme “Jarida” it is RTL supported. But it is only work with Arabic not work with URDU 🙁
I google many time but i dnt get any solution. Can you help me Please.
Thanks for this Kind deed.