xfra35 / f3-multilang

Create multilingual apps with this localization plugin for the PHP Fat-Free Framework
GNU General Public License v3.0
48 stars 13 forks source link

Detecting language not working properly #6

Closed planetahuevo closed 9 years ago

planetahuevo commented 9 years ago

Hi,

On global routes, multilang detects the browser language and loads it. The problem is that it is not working properly I think.

I have my browser options setup to use Spanish and other browser on english. Both appear with the english options on you demo: http://ml.aesx.fr/en (sidebar information). It looks like it consider the installation language and not the language set on options on the browser.

Why not use the fallback language on fatfree when the route is global?

planetahuevo commented 9 years ago

I tested your site using firefox and this plugin: https://addons.mozilla.org/en-US/firefox/addon/quick-locale-switcher/

xfra35 commented 9 years ago

Hey @planetahuevo, the Multilang plugin detects the best language available... in the case of the demo, Spanish is not available, therefore Spanish users are redirected to the primary language (English).

planetahuevo commented 9 years ago

Hi, But I was not talking about the language used on the text but the one detected and shown on the sidebar. Yesterday it was detected correctly on all pages on demo but on the global route.

Sreenshots from Google Chrome with english installation and Spanish language set on options: Frontpage: https://www.dropbox.com/s/t0g9noz7ivzuwok/Captura%20de%20pantalla%202015-03-09%2008.14.39.png?dl=0 You can see the "es" detected from the browser. This works fine on the normal multilang routes. Global route: https://www.dropbox.com/s/1thayxtmj99d4c2/Captura%20de%20pantalla%202015-03-09%2008.15.32.png?dl=0 You can see here the language is not properly detected and it shows:

Your browser settings: en-US,en;q=0.8,es;q=0.6

This happen on a incognito window, on normal window the global route sometimes it show "es" an others "en-US,en;q=0.8,es;q=0.6". Wasn´t able to find a pattern. Today I reinstalled the firefox in spanish to make sure it was not a problem with the browser and the "es" is detected properly so maybe the problem is on the browsers.

So, my suggestion is to have an option to enable/disable the autodetect on global routes. For me when the autodetect is disabled it should load the "primary" language.

Thanks

xfra35 commented 9 years ago

Hey @planetahuevo, well spotted! It was not a bug in the plugin, but in the demo. I've had defined a cache TTL of 24h on each page, which explains why you had inconsistent values displayed. Now you can clear your browser cache on everything should be ok.

FYI the value displayed in the left sidebar doesn't come from the plugin, but directly from the browser: $_SERVER['HTTP_ACCEPT_LANGUAGE'].

planetahuevo commented 9 years ago

Good to hear. So we can close this one as autodetecting is working properly. :)