From 3f2aa86ba22349984b343847dcf8c228e905ef92 Mon Sep 17 00:00:00 2001 From: Josh Barnes Date: Thu, 16 Nov 2017 00:55:26 +0000 Subject: [PATCH 1/2] Fix moment locale loading in bidi support this is the correct way to do it, especially since packaged versions of notebook are shipping without separate locale files --- notebook/static/bidi/bidi.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/notebook/static/bidi/bidi.js b/notebook/static/bidi/bidi.js index b7e9d31a0f..3e7dea272f 100644 --- a/notebook/static/bidi/bidi.js +++ b/notebook/static/bidi/bidi.js @@ -15,16 +15,10 @@ define(['bidi/numericshaping'], function(numericshaping) { 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); - }); - } + + require(['moment'], function (moment) { + console.log('Loaded moment locale', moment.locale(_uiLang())); + }); shaperType = _uiLang() == 'ar' ? 'national' : 'defaultNumeral'; }; From 60b7c22977350bdaa8dda7c8503644c4c632b09e Mon Sep 17 00:00:00 2001 From: Josh Barnes Date: Thu, 16 Nov 2017 01:17:30 +0000 Subject: [PATCH 2/2] tidy bidi support remove unused variable, redundant comment, don't need jquery --- notebook/static/bidi/bidi.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/notebook/static/bidi/bidi.js b/notebook/static/bidi/bidi.js index 3e7dea272f..9ace652e0a 100644 --- a/notebook/static/bidi/bidi.js +++ b/notebook/static/bidi/bidi.js @@ -5,7 +5,6 @@ define(['bidi/numericshaping'], function(numericshaping) { 'use strict'; var shaperType = ''; - var textDir = ''; var _uiLang = function() { return navigator.language.toLowerCase(); @@ -13,7 +12,7 @@ define(['bidi/numericshaping'], function(numericshaping) { var _loadLocale = function() { if (_isMirroringEnabled()) { - $('body').attr('dir', 'rtl'); + document.body.dir = 'rtl'; } require(['moment'], function (moment) { @@ -27,11 +26,6 @@ define(['bidi/numericshaping'], function(numericshaping) { 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 ).