commit 38b0fb26500807631a0541975a3b099b1d686a4d
parent c4d39ba79fcb12dec38821bc075c4b0c96477666
Author: Adomas VenĨkauskas <adomas.ven@gmail.com>
Date: Tue, 31 Jan 2017 19:00:15 -0300
Zotero.Promise.coroutine not supported in connector shared code (broken ef1ff8b)
Diffstat:
1 file changed, 38 insertions(+), 35 deletions(-)
diff --git a/chrome/content/zotero/xpcom/date.js b/chrome/content/zotero/xpcom/date.js
@@ -42,48 +42,51 @@ Zotero.Date = new function(){
var _months;
var _monthsWithEnglish;
- this.init = Zotero.Promise.coroutine(function* () {
+ this.init = function () {
if (!Zotero.isFx || Zotero.isBookmarklet) {
throw new Error("Unimplemented");
}
- var json = (yield Zotero.HTTP.request(
+ return Zotero.HTTP.request(
'GET', 'resource://zotero/schema/dateFormats.json', { responseType: 'json' }
- )).response;
- var locale = Zotero.locale;
- var english = locale.startsWith('en');
- // If no exact match, try first two characters ('de')
- if (!json[locale]) {
- locale = locale.substr(0, 2);
- }
- // Try first two characters repeated ('de-DE')
- 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];
+ ).then(function(xmlhttp) {
+ var json = xmlhttp.response;
+
+ var locale = Zotero.locale;
+ var english = locale.startsWith('en');
+ // If no exact match, try first two characters ('de')
+ if (!json[locale]) {
+ locale = locale.substr(0, 2);
}
- }
- // 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]);
+ // Try first two characters repeated ('de-DE')
+ 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];
+ }
+ }
+ // 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]);
+ }
+ }
+ });
});