Support » Plugin: Polylang » Language Direction Problem (RTL – LTR)

  • Resolved Morteza Rahmani


    First i want to say thank you for this great plugin.

    but unfortunatly, i have a language direction problem with polylang (v0.9.4).

    I am using it on a multisite wordpress. i created a site with 2 languages. Persian (which is RTL) & English (LTR).

    i don’t have any 3rd plugins in multisite and there are only default wordpress plugins + polylang.
    also i am using TwentyEleven Theme.

    Persian is my deafult Language and when the site loads, in html tag i see the correct values in “dir” & “lang” properties. ( <html dir=”rtl” lang=”fa-IR”> )
    but when i switch to English, “dir” property value is not being changed and it’s still on “rtl”, but the lang propery is correct (en-US). therefore the correct css styles are not being loaded.
    settings in polylang admin panel are correct for each language. (english is set to left to right & persian is set to right to left)

    i am using default permalinks.
    i unchecked to set language base on browser prefrenace.
    “The language is set from content. Posts, pages, categories and tags urls are not modified.” is choosed.
    i aslso unchecked “Hide URL language information for default language”. (checking this hadn’t fixed the problem)

    I think there are some problems in polylang core.php on lines 325 – 328.
    beacause when i manually add the following code after last else on this section (line 346 between two “}“) , the problem is fixed:

    $my_new_value = new Polylang_Core();
    	if($my_new_value_lang == 'en_US')
    	$GLOBALS['wp_locale']->text_direction = 'ltr';
    	$GLOBALS['wp_locale']->text_direction = 'rtl';

    so it will look like this:

    // reinitializes wp_locale for weekdays and months, as well as for text direction
    	$GLOBALS['wp_locale'] = new WP_Locale();
    	$GLOBALS['wp_locale']->text_direction = get_metadata('term', $this->curlang->term_id, '_rtl', true) ? 'rtl' : 'ltr';
    // translate labels of post types and taxonomies
    	foreach ($GLOBALS['wp_taxonomies'] as $tax)
    	foreach ($GLOBALS['wp_post_types'] as $pt)
    // and finally load user defined strings
    $GLOBALS['l10n']['pll_string'] = $this->mo_import($this->curlang);
    		else {
    // can't work so load the text domains with WordPress default language
    	foreach ($this->list_textdomains as $textdomain)
    	load_textdomain($textdomain['domain'], $textdomain['mo']);
    	$my_new_value = new Polylang_Core();
    	if($my_new_value_lang == 'en_US')
    	$GLOBALS['wp_locale']->text_direction = 'ltr';
    	$GLOBALS['wp_locale']->text_direction = 'rtl';

    but this is an ugly & temporary fix.
    i don’t know if it is a bug or i am doing something wrong.

    so i need your help.
    thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • sorry. the little code i pasted above has mistakes ($mori should be $my_new_value.) here is correct one:

    $my_new_value = new Polylang_Core(); $my_new_value_lang=$my_new_value->get_current_language()->description; if($my_new_value_lang == 'en_US') $GLOBALS['wp_locale']->text_direction = 'ltr'; else $GLOBALS['wp_locale']->text_direction = 'rtl';

    Plugin Author Chouby


    I remade tests using the same config as yours and don’t reproduce your problem. Could you check in the Languages settings, that the right text direction is set for English?

    thanks for you reply.

    yes i checked that before.
    English is left to right & Persian is right to left.

    so if you remaded tests with same config as mine with no problems…
    i think there be some problem with “Persian WordPress” package that i installed.

    i will try to check that.

    Plugin Author Chouby


    Yes that’s the problem. I made the test and reproduced the bug with the Persian WordPress. Should be corrected now in the development version (

    I tested this development version ( & now it works like a charm.
    Thanks Chouby. you are an amazing person 🙂

    Will this help to have different languages of both directions in the same page ?

    AliZee, if i correctly understand your question , what you are saying is look like having two html tags in same page… which is impossible.

    can you tell more details about what you want…?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Language Direction Problem (RTL – LTR)’ is closed to new replies.