Zotero.Promise.coroutine not supported in connector shared code (broken ef1ff8b)

This commit is contained in:
Adomas Venčkauskas 2017-01-31 19:00:15 -03:00
parent c4d39ba79f
commit 38b0fb2650

View file

@ -42,48 +42,51 @@ Zotero.Date = new function(){
var _months; var _months;
var _monthsWithEnglish; var _monthsWithEnglish;
this.init = Zotero.Promise.coroutine(function* () { this.init = function () {
if (!Zotero.isFx || Zotero.isBookmarklet) { if (!Zotero.isFx || Zotero.isBookmarklet) {
throw new Error("Unimplemented"); throw new Error("Unimplemented");
} }
var json = (yield Zotero.HTTP.request( return Zotero.HTTP.request(
'GET', 'resource://zotero/schema/dateFormats.json', { responseType: 'json' } 'GET', 'resource://zotero/schema/dateFormats.json', { responseType: 'json' }
)).response; ).then(function(xmlhttp) {
var locale = Zotero.locale; var json = xmlhttp.response;
var english = locale.startsWith('en');
// If no exact match, try first two characters ('de') var locale = Zotero.locale;
if (!json[locale]) { var english = locale.startsWith('en');
locale = locale.substr(0, 2); // If no exact match, try first two characters ('de')
} if (!json[locale]) {
// Try first two characters repeated ('de-DE') locale = locale.substr(0, 2);
if (!json[locale]) {
locale = locale + "-" + locale.toUpperCase();
}
// Look for another locale with same first two characters
if (!json[locale]) {
let sameLang = Object.keys(json).filter(l => l.startsWith(locale.substr(0, 2)));
if (sameLang.length) {
locale = sameLang[0];
} }
} // Try first two characters repeated ('de-DE')
// If all else fails, use English if (!json[locale]) {
if (!json[locale]) { locale = locale + "-" + locale.toUpperCase();
locale = 'en-US';
english = true;
}
_months = json[locale];
// Add English versions if not already added
if (english) {
_monthsWithEnglish = _months;
}
else {
_monthsWithEnglish = {};
for (let key in _months) {
_monthsWithEnglish[key] = _months[key].concat(json['en-US'][key]);
} }
} // Look for another locale with same first two characters
if (!json[locale]) {
let sameLang = Object.keys(json).filter(l => l.startsWith(locale.substr(0, 2)));
if (sameLang.length) {
locale = sameLang[0];
}
}
// If all else fails, use English
if (!json[locale]) {
locale = 'en-US';
english = true;
}
_months = json[locale];
// Add English versions if not already added
if (english) {
_monthsWithEnglish = _months;
}
else {
_monthsWithEnglish = {};
for (let key in _months) {
_monthsWithEnglish[key] = _months[key].concat(json['en-US'][key]);
}
}
});
}); });