Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

Chouby on "[Plugin: Polylang] browser language according is not working, $_COOKIE[pll_language] not working"

$
0
0

Sorry for being so long to understand :(

Polylang first compares this code to the browser preferences. A match is found if the browser preference starts by the language code 'cn'. In your case it can't happen as this code does not exist.

Then there is a second try to compare the locale (zh-CN) with the browser preferences. So it won't work if only 'zh' is in browser preference but should work if there is 'zh-CN'. The issue is that this comparison is case sensitive and:
Chrome sends zh-CN
while Firefox sends zh-cn :(

So please try modifying the file frontend/choose-lang.php at line 115 from

if (empty($pref_lang) && (0 === stripos($accept_lang, $language->slug) || $accept_lang == str_replace('_', '-', $language->locale)) )

to

if (empty($pref_lang) && (0 === stripos($accept_lang, $language->slug) || 0 === strcmp($accept_lang, str_replace('_', '-', $language->locale))) )

Viewing all articles
Browse latest Browse all 11471

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>