Skip to content

Commit

Permalink
OC.getLocale() now returns Locale and no longer Language
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tcitworld committed Jul 17, 2017
1 parent 736c631 commit a79e02d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions core/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},

Expand Down
2 changes: 1 addition & 1 deletion core/templates/layout.user.php
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
2 changes: 1 addition & 1 deletion lib/private/L10N/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion lib/private/TemplateLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit a79e02d

Please sign in to comment.