aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2017-07-17 10:08:51 +0200
committerGeorg Ehrke <developer@georgehrke.com>2018-06-27 13:19:40 +0200
commitbf6bfad76bcf40266f7a7bdc71cbf59e8873abe7 (patch)
tree321bdc812bcdb406eec85d5405ea7d8b527a307a
parent7d8124ad66d336b99c48936e2a6a84ea4d0fef09 (diff)
downloadnextcloud-server-bf6bfad76bcf40266f7a7bdc71cbf59e8873abe7.tar.gz
nextcloud-server-bf6bfad76bcf40266f7a7bdc71cbf59e8873abe7.zip
OC.getLocale() now returns Locale and no longer Language
Added OC.getLanguage() to get Language <html lang=''> still gets language, though according to IETF BCP47 locale should be good. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
-rw-r--r--core/js/js.js9
-rw-r--r--core/templates/layout.user.php2
-rw-r--r--lib/private/L10N/Factory.php2
-rw-r--r--lib/private/TemplateLayout.php3
4 files changed, 13 insertions, 3 deletions
diff --git a/core/js/js.js b/core/js/js.js
index a7dba7981f7..3cd8f306044 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -791,6 +791,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 44820c4a9a8..3cac14b4ab3 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html class="ng-csp" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" >
+<html class="ng-csp" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" data-locale="<?php p($_['locale']); ?>" >
<head data-user="<?php p($_['user_uid']); ?>" data-user-displayname="<?php p($_['user_displayname']); ?>" data-requesttoken="<?php p($_['requesttoken']); ?>">
<meta charset="utf-8">
<title>
diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php
index 86f2ab3b1f0..8c35d75a4b5 100644
--- a/lib/private/L10N/Factory.php
+++ b/lib/private/L10N/Factory.php
@@ -195,7 +195,7 @@ class Factory implements IFactory {
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 c378396c727..be81608f074 100644
--- a/lib/private/TemplateLayout.php
+++ b/lib/private/TemplateLayout.php
@@ -131,10 +131,11 @@ class TemplateLayout extends \OC_Template {
parent::__construct('core', 'layout.base');
}
- // Send the language to our layouts
+ // Send the language and the locale to our layouts
$lang = \OC::$server->getL10NFactory()->findLanguage();
$lang = str_replace('_', '-', $lang);
$this->assign('language', $lang);
+ $this->assign('locale', \OC::$server->getL10NFactory()->findLocale());
if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
if (empty(self::$versionHash)) {