From c82138567e799dfede4e4d47b3b197430ae978d0 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 4 Mar 2011 18:34:35 -0500 Subject: [PATCH] Allow fallback to en-US for missing files in the selected locale. --- common/components/protocols.js | 13 +++++++++++-- common/modules/javascript.jsm | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/common/components/protocols.js b/common/components/protocols.js index 21388b78..4d5cb792 100644 --- a/common/components/protocols.js +++ b/common/components/protocols.js @@ -190,9 +190,9 @@ Dactyl.prototype = { return redirect("dactyl://help/" + this.HELP_TAGS[tag] + "#" + tag.replace(/#/g, encodeURIComponent), uri); break; case "locale": - return makeChannel(["resource://dactyl-locale", config.locale, path].join("/"), uri); + return LocaleChannel("dactyl-locale", path, uri); case "locale-local": - return makeChannel(["resource://dactyl-local-locale", config.locale, path].join("/"), uri); + return LocaleChannel("dactyl-local-locale", path, uri); } } catch (e) { @@ -216,6 +216,15 @@ Dactyl.prototype = { } }; +function LocaleChannel(base, path, orig) { + for each (let locale in [config.locale, "en-US"]) { + var channel = makeChannel(["resource:/", base, config.locale, path].join("/"), orig); + if (channel.name !== DNE) + break; + } + return channel; +} + function StringChannel(data, contentType, uri) { let channel = services.StreamChannel(uri); channel.contentStream = services.StringStream(data); diff --git a/common/modules/javascript.jsm b/common/modules/javascript.jsm index 733f3d65..a2c18266 100644 --- a/common/modules/javascript.jsm +++ b/common/modules/javascript.jsm @@ -75,7 +75,8 @@ var JavaScript = Module("javascript", { let globals = values(toplevel && this.window === obj ? this.globalNames : []); if (toplevel && isObject(obj) && "wrappedJSObject" in obj) - yield "wrappedJSObject"; + if (!set.add(seen, "wrappedJSObject")) + yield "wrappedJSObject"; for (let key in iter(globals, properties(obj, !toplevel, true))) if (!set.add(seen, key))