Language and Country Detection bugs #504

Closed
robocoder opened this Issue Jan 15, 2009 · 6 comments

2 participants

@robocoder
  • 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()
@robocoder

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
@robocoder

Attachment:
[504.diffs](http://issues.piwik.org/attachments/504/504.diffs)

@robocoder

Attachment: new
[LanguageToCountry.php](http://issues.piwik.org/attachments/504/LanguageToCountry.php)

@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
@mattab
Piwik Open Source Analytics member

end of fix in 931; thanks anthon!

@robocoder

(In 1038) refs #504 – check that valid_languages and valid_countries is not null;
http://ca2.php.net/manual/en/function.in-array.php#86695 describes
in_array() returning true if haystack is 0 or false, and not in strict
mode

@robocoder robocoder added this to the RobotRock milestone Jul 8, 2014
@robocoder robocoder self-assigned this Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment