Use hard-coded list for default script direction

This commit is contained in:
Sylvester Keil 2018-07-30 13:23:54 +02:00
parent 94539ceac5
commit cc47a3aab5
No known key found for this signature in database
GPG key ID: 878933BCEAB25A10
2 changed files with 13 additions and 16 deletions

View file

@ -47,21 +47,7 @@ Zotero.Intl = new function () {
.GetStringFromName('brandShortName'); .GetStringFromName('brandShortName');
// Set the locale direction to Zotero.dir // Set the locale direction to Zotero.dir
Zotero.dir = 'ltr'; Zotero.dir = Zotero.Locale.defaultScriptDirection(Zotero.locale);
// TODO: is there a better way to get the entity from JS?
if (!(Zotero.isNode || Zotero.isElectron)) {
let xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
xmlhttp.open('GET', 'chrome://global/locale/global.dtd', false);
xmlhttp.overrideMimeType('text/plain');
xmlhttp.send(null);
let matches = xmlhttp.responseText.match(/(ltr|rtl)/);
if (matches && matches[0] == 'rtl') {
Zotero.dir = 'rtl';
}
}
Zotero.rtl = (Zotero.dir === 'rtl'); Zotero.rtl = (Zotero.dir === 'rtl');
}; };

View file

@ -40,5 +40,16 @@ Zotero.Locale = {
'vi-VN': 'Tiếng Việt', 'vi-VN': 'Tiếng Việt',
'zh-CN': '中文 (简体)', 'zh-CN': '中文 (简体)',
'zh-TW': '正體中文 (繁體)' 'zh-TW': '正體中文 (繁體)'
}) }),
defaultScriptDirection(locale) {
switch (locale.split('-')[0]) {
case 'ar':
case 'fa':
case 'he':
return 'rtl';
default:
return 'ltr';
}
}
} }