Closed notabeatle closed 4 years ago
Specific behavior addressed:
1) Add a second language, after your default (say, en as default, fr as the second)
2) Make sure skip_default_l10n is set to false.
3) Visit "example.com/" with en as your browser's preferred language. Be redirected to "example.com/en/".
4) Visit "example.com/" with fr as your browser's preferred language. Be redirected to "example.com/fr/"
5) Set skip_default_l10n
6) Visit "example.com/" with en as your browser's preferred language. No redirection, English site displayed.
So far, so good!
7) Visit "example.com/" with fr as your browser's preferred language. No redirection, English site displayed.
That's the bad part.
With this change, 7) now redirects to "example/fr/" while the rest remains the same (as it should).
Impelementing my own patch to this due to some other changes I wanna make
User agent language preferences were ignored when skip_default_l10n was true, unless a language was explicitly provided.
This change causes nLingual to consider user agent language preferences even if skip_default_l10n is true, while still retaining standard WP URLs for the default language. That is, a request to "example.com" with a default language of "en" and a user agent preference for "fr" will redirect to "example.com/fr/", assuming it exists; before, it would not do this unless skip_default_l10n was set to false and default language requests were redirected to "example.com/en/", also.
This also fixes a small redirect-loop-causing bug encountered with certain settings, when explicitly requesting a default language root path like "example.com/en" with no trailing slash.
Fixes #12