From 286ac1ddab0a6a81dd4c6d806a906554b3aae633 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 17 Jul 2017 10:08:51 +0200 Subject: [PATCH] OC.getLocale() now returns Locale and no longer Language Added OC.getLanguage() to get Language still gets language, though according to IETF BCP47 locale should be good. Signed-off-by: Thomas Citharel --- core/js/js.js | 9 +++++++++ core/templates/layout.user.php | 2 +- lib/private/L10N/Factory.php | 2 +- lib/private/TemplateLayout.php | 3 ++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/core/js/js.js b/core/js/js.js index 2aa7bf1bc558d..0364148d82264 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -757,6 +757,15 @@ var OCP = {}, * @return {String} locale string */ getLocale: function() { + return $('html').prop('data-locale'); + }, + + /** + * Returns the user's language + * + * @returns {String} language string + */ + getLanguage: function () { return $('html').prop('lang'); }, diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 337032ab66479..f9f9b295c50e5 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -1,5 +1,5 @@ - + diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index e82a1ad84d8d7..ba83560f0315d 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -185,7 +185,7 @@ public function findLanguage($app = null) { return 'en'; } - public function findLocale($app = null, $lang = null) + public function findLocale($lang = null) { if ($this->config->getSystemValue('installed', false)) { $userId = null !== $this->userSession->getUser() ? $this->userSession->getUser()->getUID() : null; diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 9e9ec709cf5ff..e9d9a3c05c522 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -115,8 +115,9 @@ public function __construct( $renderAs, $appId = '' ) { parent::__construct('core', 'layout.base'); } - // Send the language to our layouts + // Send the language and the locale to our layouts $this->assign('language', \OC::$server->getL10NFactory()->findLanguage()); + $this->assign('locale', \OC::$server->getL10NFactory()->findLocale()); if(\OC::$server->getSystemConfig()->getValue('installed', false)) { if (empty(self::$versionHash)) {