WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] Language Direction Problem (RTL - LTR) (8 posts)

  1. parsilinux
    Member
    Posted 1 year ago #

    Hi.
    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();
    $my_new_value_lang=$mori->get_current_language()->description;
    	if($my_new_value_lang == 'en_US')
    	$GLOBALS['wp_locale']->text_direction = 'ltr';
    	else
    	$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
    	unset($GLOBALS['wp_locale']);
    	$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)
    	$this->translate_labels($tax);
    	foreach ($GLOBALS['wp_post_types'] as $pt)
    	$this->translate_labels($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();
    	$my_new_value_lang=$mori->get_current_language()->description;
    	if($my_new_value_lang == 'en_US')
    	$GLOBALS['wp_locale']->text_direction = 'ltr';
    	else
    	$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.

    http://wordpress.org/extend/plugins/polylang/

  2. parsilinux
    Member
    Posted 1 year ago #

    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';

  3. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    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?

  4. parsilinux
    Member
    Posted 1 year ago #

    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.

  5. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    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 (0.9.4.6)
    http://downloads.wordpress.org/plugin/polylang.zip

  6. parsilinux
    Member
    Posted 1 year ago #

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

  7. AliZee
    Member
    Posted 1 year ago #

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

  8. parsilinux
    Member
    Posted 1 year ago #

    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...?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic