Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix moment locale loading in bidi support #3048

Merged
merged 2 commits into from
Nov 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions notebook/static/bidi/bidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,27 @@ define(['bidi/numericshaping'], function(numericshaping) {
'use strict';

var shaperType = '';
var textDir = '';

var _uiLang = function() {
return navigator.language.toLowerCase();
};

var _loadLocale = function() {
if (_isMirroringEnabled()) {
$('body').attr('dir', 'rtl');
}
var uiLang = _uiLang();

if (uiLang !== 'en' && uiLang !== 'en-us') {
// moment does not ship with a separate file for locale/en or locale/en-us
// so we must skip dynamically requiring it
requirejs(['components/moment/locale/' + _uiLang()], function(err) {
console.warn('Error loading the required locale');
console.warn(err);
});
document.body.dir = 'rtl';
}

require(['moment'], function (moment) {
console.log('Loaded moment locale', moment.locale(_uiLang()));
});

shaperType = _uiLang() == 'ar' ? 'national' : 'defaultNumeral';
};

var _isMirroringEnabled = function() {
return new RegExp('^(ar|he)').test(_uiLang());
};

/**
* NS : for digit Shaping.
* BTD : for future work in case of Base Text Direction Addition.
*/

/**
* @param value : the string to apply the bidi-support on it.
* @param flag :indicates the type of bidi-support (Numeric-shaping ,Base-text-dir ).
Expand Down