Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Support for multilanguage sites, Internationalization (I18N)
HTTP_ACCEPT_LANGUAGE is still a problem in V 3.3.2.

Today when I searched Google for my new project, I found in the preview (and in the Google cache):

Code:
Warning: Undefined array key "HTTP_ACCEPT_LANGUAGE" in /mydomainroot/plugins/i18n_base/frontend.class.php on line 24

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /mydomainroot/plugins/i18n_base/frontend.class.php on line 24

So it seems that Google (and who else?) does not always send a HTTP_ACCEPT_LANGUAGE header, but at least sometimes omits it, resulting in the error message above. So we cannot rely on its existance.

Line 23 of frontend.class.php tries to consider this problem in advance (before line 24), but fails:
PHP Code:
if (!defined('I18N_IGNORE_USER_LANGUAGE') || !I18N_IGNORE_USER_LANGUAGE && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { 

To me this looks like a precedence problem. The "&&" precedes over the "||".
This results in grouping the last two conditions together, instead of the first two conditions.
See also https://www.php.net/manual/en/language.o...edence.php
In order to avoid this, parentheses should be used.

So the solution might be
PHP Code:
if ((!defined('I18N_IGNORE_USER_LANGUAGE') || !I18N_IGNORE_USER_LANGUAGE) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { 

Please let me know what you think about this.
Best regards,
Knobbles
Reply


Messages In This Thread
rewrite language problem - by tomkop - 2013-03-27, 06:34:44
Enhancement suggestion - by hameau - 2013-05-12, 04:17:12
Enhancement request - by hameau - 2013-06-14, 20:02:07
RE: Enhancement request - by mvlcek - 2013-06-14, 22:04:12
RE: Enhancement request - by hameau - 2013-06-14, 23:01:36
Duplicate language cookies bug - by enzy - 2013-08-20, 07:03:26
RE: Duplicate language cookies bug - by ohayo - 2013-08-20, 18:12:25
Plugin is not shown - by tosho - 2013-09-15, 12:10:37
1000 pages limit in i18n_navigation - by titus - 2014-10-13, 21:58:36
Bug found - by lbarsov - 2014-10-17, 03:41:53
Menu with picture - by Dimi - 2015-04-28, 16:05:45
Rendering Menu in Component - by Alexander_ - 2016-05-04, 23:06:51
Meta desc for different languages - by Alexander_ - 2017-02-14, 20:29:32
Hierarchical Menus - by celextel - 2019-07-26, 16:41:47
Ri18n_navigation - by celextel - 2021-02-19, 16:07:48
RE: Support for multilanguage sites, Internationalization (I18N) - by Knobbles - 2023-10-07, 02:28:41



Users browsing this thread: 7 Guest(s)