default language by polylang plugin not working
Asked Answered
S

11

10

I installed Polylang Plugin and configed that but I have a problem when I set the default language in Persian language the site loaded in English mode and it is not deference if change default language because in any way in run site loaded by English version. I installed 3 languages: Persian, English, French Wordpress version is 4.1.1 and Polylang Plugin version is 1.8.5 How can I fixed the default language in fa-IR? please help me

Sorel answered 18/4, 2016 at 10:41 Comment(0)
S
6

this solution isn't standard! but work for me :)

replace (comment) this line in wp-content/plugins/polylang/frontend/choose-lang.php file (line 185)

$language = $this->options['hide_default'] && ( ( isset( $_SERVER['HTTP_REFERER'] ) && in_array( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_HOST ), $this->links_model->get_hosts() ) ) || ! $this->options['browser'] ) ?
        $this->model->get_language( $this->options['default_lang'] ) :
        $this->get_preferred_language();  // sets the language according to browser preference or default language

by

$language = 'fa';
Sidnee answered 19/4, 2016 at 18:35 Comment(0)
V
23

For me it was the Polylang setting

Detect browser language (When the front page is visited, set the language according to the browser preference).

Found in wp-admin > languages > settings.

Test to uncheck that.

Vic answered 7/4, 2017 at 7:33 Comment(1)
This is the correct procedure and this option is for that settings specially. no one should touch the code without looking for proper settings.Delhi
C
9

You can set default language by click on star in Polylang 'Languages' page, there will be a star for default language when someone is visiting your website. Also, don't forget to deactivate detect browser language in Polylang 'Settings' page, I hope this will work. This works fine for me.

Colon answered 25/4, 2017 at 6:19 Comment(0)
S
6

this solution isn't standard! but work for me :)

replace (comment) this line in wp-content/plugins/polylang/frontend/choose-lang.php file (line 185)

$language = $this->options['hide_default'] && ( ( isset( $_SERVER['HTTP_REFERER'] ) && in_array( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_HOST ), $this->links_model->get_hosts() ) ) || ! $this->options['browser'] ) ?
        $this->model->get_language( $this->options['default_lang'] ) :
        $this->get_preferred_language();  // sets the language according to browser preference or default language

by

$language = 'fa';
Sidnee answered 19/4, 2016 at 18:35 Comment(0)
H
2

This is not a perfect solution but works for me. Change the following line in wp-content/plugins/polylang/frontend/choose-lang.php (Line no 247):

$this->set_language( $language ); 

to:

$this->set_language( 'ar' ); //set defalt language name.
Heptamerous answered 4/11, 2020 at 10:37 Comment(0)
F
0

If someone still having this problem. I had the same issue with Polylang. I was not able to switch back to English after switching to Arabic. The problem had the easiest solution though. It appeared I forgot to set Site Language of WP itself in Settings>General as English UK (it was set to English US). After I changed that all worked fine.

Fleischer answered 20/7, 2020 at 9:0 Comment(0)
F
0

ok i have solution. not need any code. when you set default language then need to go settings - than - URL modifications settings and mark first (The language is set from content) enter image description here

Flittermouse answered 30/10, 2020 at 14:45 Comment(0)
P
0

is someone have still problem with this, i found solution. Go to DB > ptqsln_options (you have maybe different prefix) > polylang and at end of json is default_lang and change to your language. It works for me.

Ponton answered 21/12, 2021 at 8:1 Comment(0)
A
0

I had the same issue. My site was built in Mandarain first. Now, I'm adding English, but Polylang keeps saying the default is English and gives me tons of trouble when adding pages. I've figured out how to fix that.

  1. Go to Language Settings, add the correct "default" language. In my case, Chinese. And double click it then you will see a star on it.

  2. You will also see a star on the first row, the English one, which attaches many pages. And it has a star. Double click to unstar it. Now Polylang will think your default will be the only option soon.

  3. Delete the first English one, which has many pages linked to it. (There's no need to back up.) Don't worry, it won't delete any pages. At this time, you only have one language option for Polylang; in my case, Chinese.

  4. Run the setup wizard again. And you will see Polyland says the site's default language is in Chinese. (Or your correct default one.) Congrats! Now finish the setup as normal.

  5. Go back to the Languages, and add English or the correct intended language back. Then you will see this new English has 0 posts attached to it, and the correct Default Lan has all of the posts to it!

Aramanta answered 15/7, 2022 at 21:25 Comment(1)
this works perfectly for me. but be careful: if you already have pages translated into other languages, the link to the translations will get lost with this method!Ettaettari
B
0

For me it was the language setting for my user (you can set the language there, too). Also check the general language setting, too, of course.

Brendanbrenden answered 4/6 at 9:57 Comment(0)
E
0

In my case the solution was the correct language code:

My WP installation was set to de_AT. my mistake was that i had chosen the wrong language code (de_DE) for the "Locale" field using the setup wizard.

Under Languages, click on Edit under the language you want to edit in the list. go to the left and enter the right language code in the "Locale" field, hit Update.

Ettaettari answered 23/8 at 8:56 Comment(0)
B
-1

Go to Settings > General and change the Site Language to Farsi. That will change the language of the admin part. Is this what you've been looking for?

Brister answered 18/4, 2016 at 10:52 Comment(3)
I know that but I don't want to change admin panel language but I want to fix the Farsi language when visitors go on my website. For example if my domain is www.example.com it loaded by this URL www.example.com/en in English version but i want to loaded that in www.example.com/fa in Farsi version.Sorel
Have you added Farsi translation of your content?Brister
Yes I do and Farsi is set for default language in configuration plugin but it is not working!Sorel

© 2022 - 2024 — McMap. All rights reserved.