diff options
Diffstat (limited to 'plugins/UserSettings/Columns/Language.php')
-rw-r--r-- | plugins/UserSettings/Columns/Language.php | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/plugins/UserSettings/Columns/Language.php b/plugins/UserSettings/Columns/Language.php index f61154c7c4..4f31778e2d 100644 --- a/plugins/UserSettings/Columns/Language.php +++ b/plugins/UserSettings/Columns/Language.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugins\UserSettings\Columns; +use Piwik\Common; use Piwik\Piwik; use Piwik\Plugin\Dimension\VisitDimension; use Piwik\Tracker\Action; @@ -32,12 +33,22 @@ class Language extends VisitDimension */ public function onNewVisit(Request $request, Visitor $visitor, $action) { - $language = $request->getBrowserLanguage(); + return $this->getSingleLanguageFromAcceptedLanguages($request->getBrowserLanguage()); + } - if (empty($language)) { + /** + * For better privacy we store only the main language code, instead of the whole browser language string. + * + * @param $acceptLanguagesString + * @return string + */ + protected function getSingleLanguageFromAcceptedLanguages($acceptLanguagesString) + { + if (empty($acceptLanguagesString)) { return ''; } - return substr($language, 0, 20); + $languageCode = Common::extractLanguageAndRegionCodeFromBrowserLanguage($acceptLanguagesString); + return $languageCode; } -}
\ No newline at end of file +} |