Language Direction Problem (RTL – LTR)
-
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.
The topic ‘Language Direction Problem (RTL – LTR)’ is closed to new replies.