Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#504 closed Bug (fixed)

Language and Country Detection bugs

Reported by: vipsoft Owned by: vipsoft
Priority: major Milestone: RobotRock
Component: Core Keywords:
Cc: Sensitive:


  • core/Common.php: extractLanguageCodeFromBrowserLanguage returns the country code;

should rename this to extractCountryCodeFromBrowserLanguage and add a new extractLanguageCodeFromBrowserLanguage function

  • plugins/LanguagesManager/LanguagesManager.php: calls above function, extractLanguageCodeFromBrowserLanguage, expecting a language code, but for "en-ca", it gets "ca" (Català) instead of "en"
  • Visitors | Locations & providers | Countries data table shows "Unknown" for "en-US"; need to call strtolower(), probably in core/Common.php's getBrowserlanguage()

Attachments (2)

504.diffs (24.6 KB) - added by vipsoft 5 years ago.
LanguageToCountry.php (2.3 KB) - added by vipsoft 5 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 5 years ago by vipsoft (robocoder)

  • Milestone changed from RobotRock to DigitalVibes

comment:2 Changed 5 years ago by matt (mattab)

  • Milestone changed from DigitalVibes to RobotRock

comment:3 Changed 5 years ago by vipsoft (robocoder)

  • Owner set to vipsoft
  • Status changed from new to assigned

comment:4 Changed 5 years ago by vipsoft (robocoder)

  • Type changed from Task to Bug

Tasks from #504:

  • rename lang/cn.php to lang/zh-cn.php
  • rename lang/tw.php to lang/zh-tw.php

I'm guessing this one should be renamed too (judging from General_Locale):

  • rename lang/pt.php to lang/pt-br.php

Changed 5 years ago by vipsoft (robocoder)

Changed 5 years ago by vipsoft (robocoder)


comment:5 Changed 5 years ago by vipsoft (robocoder)

Updated patch (and new file):

  • config/global.ini.php: added config option 'enable_language_to_country_guess' to turn on the language to country guess (when no region provided in the preferred language tag)
  • core/DataFiles/LanguageToCountry.php: new
  • core/DataFiles/Countries.php: updated with respect to ISO 3166-1 alpha-2 list
  • lang/en.php: updated with respect to above
  • tests/core/Common.test.php: more tests
  • core/Common.php: lots of changes

comment:6 Changed 5 years ago by matt (mattab)

  • Resolution set to fixed
  • Status changed from assigned to closed

end of fix in [931]; thanks anthon!

comment:7 Changed 5 years ago by vipsoft (robocoder)

(In [1038]) refs #504 - check that valid_languages and valid_countries is not null; describes
in_array() returning true if haystack is 0 or false, and not in strict

Note: See TracTickets for help on using tickets.