- fix Zotero.loadTranslator() from sandbox

- add (currently only en-US) months to Zotero.Date for connectors (localization is #1830)
This commit is contained in:
Simon Kornblith 2011-06-17 20:05:48 +00:00
parent 48b5bc8bee
commit 55280e5256
2 changed files with 32 additions and 19 deletions

View file

@ -51,6 +51,7 @@ Zotero.Date = new function(){
* Load dateFormat bundle into _dateFormatsBundle * Load dateFormat bundle into _dateFormatsBundle
*/ */
function _loadDateFormatsBundle() { function _loadDateFormatsBundle() {
if(Zotero.isFx) {
var src = 'chrome://global/locale/dateFormat.properties'; var src = 'chrome://global/locale/dateFormat.properties';
var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1']. var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1'].
getService(Components.interfaces.nsILocaleService); getService(Components.interfaces.nsILocaleService);
@ -65,6 +66,14 @@ Zotero.Date = new function(){
_months.short.push(bundle.GetStringFromName("month."+i+".Mmm")); _months.short.push(bundle.GetStringFromName("month."+i+".Mmm"));
_months.long.push(bundle.GetStringFromName("month."+i+".name")); _months.long.push(bundle.GetStringFromName("month."+i+".name"));
} }
} else {
// TODO localize for Chrome/Safari
_months = {
"short":["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
"Oct", "Nov", "Dec"],
"long":["January", "February", "March", "April", "May", "June", "July",
"Auguest", "September", "October", "November", "December"]};
}
} }
/** /**

View file

@ -181,11 +181,15 @@ Zotero.Translate.Sandbox = {
translation.setHandler(arg1, translation.setHandler(arg1,
function(obj, item) { function(obj, item) {
try { try {
// necessary to get around object wrappers if(arg1 == "itemDone") {
if(Zotero.isFx && arg1 == "itemDone" if(Zotero.isFx && (translate instanceof Zotero.Translate.Web
&& (translate instanceof Zotero.Translate.Web
|| translate instanceof Zotero.Translate.Search)) { || translate instanceof Zotero.Translate.Search)) {
// necessary to get around object wrappers in Firefox
item = translate._sandboxManager.sandbox.Zotero._transferItem(JSON.stringify(item)); item = translate._sandboxManager.sandbox.Zotero._transferItem(JSON.stringify(item));
} else {
// otherwise, just use parent translator's complete function
item.complete = translate._sandboxManager.sandbox.Zotero.Item.prototype.complete;
}
} }
arg2(obj, item); arg2(obj, item);
} catch(e) { } catch(e) {
@ -665,7 +669,7 @@ Zotero.Translate.Base.prototype = {
} }
for(var i in this._handlers[type]) { for(var i in this._handlers[type]) {
Zotero.debug("Translate: running handler "+i+" for "+type, 5); Zotero.debug("Translate: Running handler "+i+" for "+type, 5);
try { try {
returnValue = this._handlers[type][i].apply(null, args); returnValue = this._handlers[type][i].apply(null, args);
} catch(e) { } catch(e) {