-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Bidi support #2357
Merged
Merged
Bidi support #2357
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4013cd8
enable the localization mode
samarsultan c663389
configure the moment-hijri plugin
samarsultan ea72fe3
Creating bidi interface
samarsultan ad63cfd
Creating digit shaping core
samarsultan 243a3f8
Bidi Support
samarsultan 6f12638
tuning bidi support
samarsultan a87528c
tuning rtl mode
samarsultan 2d0be35
Tuning bidi support
samarsultan f21969d
tuning rtl mode style for login page
samarsultan e112142
tuning rtl mode style for commanpalette window
samarsultan 29ce7de
tuning code style
samarsultan b5258c3
removing moment-hijri path
samarsultan 7fee844
Update notebooklist.js
samarsultan ca244e7
Update savewidget.js
samarsultan 57da7fa
Resolving Conflicts
samarsultan 3e0c87d
tuning code style
samarsultan 142b74b
updating bidi and numericshaping files
samarsultan c4385eb
removing setUserPreference function
samarsultan 048befc
update savewidget.js
samarsultan 28fcc7b
update notebooklist.js
samarsultan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
|
||
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"); | ||
} | ||
requirejs(['components/moment/locale/'+_uiLang()], function (err){ | ||
console.warn("Error loading the required locale"); | ||
console.warn(err); | ||
}); | ||
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. | ||
*/ | ||
/*var _flags= { | ||
NS: 1, | ||
BTD : 2 | ||
};*/ | ||
|
||
/** | ||
* @param value : the string to apply the bidi-support on it. | ||
* @param flag :indicates the type of bidi-support (Numeric-shaping ,Base-text-dir ). | ||
*/ | ||
var _applyBidi = function (value /*, flag*/) { | ||
value = numericshaping.shapeNumerals(value, shaperType); | ||
return value; | ||
}; | ||
|
||
var bidi = { | ||
applyBidi : _applyBidi, | ||
isMirroringEnabled : _isMirroringEnabled, | ||
loadLocale : _loadLocale, | ||
}; | ||
|
||
return bidi; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
|
||
define([], | ||
function(bidi) { | ||
"use strict"; | ||
|
||
var regex = /([0-9])|([\u0660-\u0669])|([\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FF\u0750-\u077F\u08A0-\u08E3\u200F\u202B\u202E\u2067\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFC\uFDFE-\uFDFF\uFE70-\uFEFE]+)|([^0-9\u0660-\u0669\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FF\u0750-\u077F\u08A0-\u08E3\u200F\u202B\u202E\u2067\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFC\uFDFE-\uFDFF\uFE70-\uFEFE\u0600-\u0607\u0609-\u060A\u060C\u060E-\u061A\u064B-\u066C\u0670\u06D6-\u06E4\u06E7-\u06ED\u06F0-\u06F9\u08E4-\u08FF\uFD3E-\uFD3F\uFDD0-\uFDEF\uFDFD\uFEFF\u0000-\u0040\u005B-\u0060\u007B-\u007F\u0080-\u00A9\u00AB-\u00B4\u00B6-\u00B9\u00BB-\u00BF\u00D7\u00F7\u02B9-\u02BA\u02C2-\u02CF\u02D2-\u02DF\u02E5-\u02ED\u02EF-\u02FF\u2070\u2074-\u207E\u2080-\u208E\u2100-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A-\u213B\u2140-\u2144\u214A-\u214D\u2150-\u215F\u2189\uA720-\uA721\uA788\uFF01-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFE0-\uFFE6\uFFE8-\uFFEE]+)/g; | ||
|
||
var shape = function(text, shaperType) { | ||
text = text.toString(); | ||
if (!text) { | ||
return text; | ||
} | ||
switch (shaperType) { | ||
case "defaultNumeral": | ||
return _shapeEuropean(text); | ||
case "national": | ||
return _shapeArabic(text); | ||
default: | ||
return text; | ||
} | ||
}; | ||
|
||
var _shapeEuropean = function(text) { | ||
return text.replace(/[\u0660-\u0669]/g, function(c) { | ||
return c.charCodeAt(0) - 1632; | ||
}); | ||
}; | ||
|
||
var _shapeArabic = function(text) { | ||
return text.replace(/[0-9]/g, function(c) { | ||
return String.fromCharCode(parseInt(c) + 1632); | ||
}); | ||
}; | ||
|
||
var numericshaping = { | ||
shapeNumerals : shape | ||
}; | ||
|
||
return numericshaping; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to special case
en
anden-us
since the files are not there and are the builtins from moment: moment/moment#2081There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you already took care of it! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah I should have noted that again here. Good to go now.