From 4f13f9698171f8041a443a1c1f0c8fbd4522ca77 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 25 Aug 2015 15:47:31 +0200 Subject: [PATCH] Save detected l10n of browser on login * fixes owncloud/activity#373 --- lib/private/l10n.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/private/l10n.php b/lib/private/l10n.php index d367dbae69..17acaac169 100644 --- a/lib/private/l10n.php +++ b/lib/private/l10n.php @@ -449,8 +449,11 @@ class OC_L10N implements \OCP\IL10N { return self::$language; } - if(OC_User::getUser() && \OC::$server->getConfig()->getUserValue(OC_User::getUser(), 'core', 'lang')) { - $lang = \OC::$server->getConfig()->getUserValue(OC_User::getUser(), 'core', 'lang'); + $config = \OC::$server->getConfig(); + $userId = \OC_User::getUser(); + + if($userId && $config->getUserValue($userId, 'core', 'lang')) { + $lang = $config->getUserValue($userId, 'core', 'lang'); self::$language = $lang; if(is_array($app)) { $available = $app; @@ -463,13 +466,18 @@ class OC_L10N implements \OCP\IL10N { } } - $default_language = \OC::$server->getConfig()->getSystemValue('default_language', false); + $default_language = $config->getSystemValue('default_language', false); if($default_language !== false) { return $default_language; } - return self::setLanguageFromRequest($app); + $lang = self::setLanguageFromRequest($app); + if($userId && !$config->getUserValue($userId, 'core', 'lang')) { + $config->setUserValue($userId, 'core', 'lang', $lang); + } + + return $lang; } /**