diff --git a/app/assets/javascripts/locales/i18n.js b/app/assets/javascripts/locales/i18n.js index 0f2153e103..ddf3fd55f1 100644 --- a/app/assets/javascripts/locales/i18n.js +++ b/app/assets/javascripts/locales/i18n.js @@ -73,7 +73,13 @@ I18n.lookup = function(scope, options) { messages = messages[currentScope]; } - messages = messages || checkExtras(origScope, this.SEPARATOR, this.extras) || options.defaultValue; + if (messages === undefined) { + messages = checkExtras(origScope, this.SEPARATOR, this.extras); + } + + if (messages === undefined) { + messages = options.defaultValue; + } return messages; }; diff --git a/test/javascripts/lib/i18n-test.js.es6 b/test/javascripts/lib/i18n-test.js.es6 index 5a106a6b01..9fbfa7beac 100644 --- a/test/javascripts/lib/i18n-test.js.es6 +++ b/test/javascripts/lib/i18n-test.js.es6 @@ -27,7 +27,8 @@ module("lib:i18n", { "en": { "js": { "hello": { - "world": "Hello World!" + "world": "Hello World!", + "universe": "" }, "topic": { "reply": { @@ -68,6 +69,7 @@ test("translations", function() { equal(I18n.t("topic.reply.title"), "Répondre", "uses locale translations when they exist"); equal(I18n.t("topic.reply.help"), "begin composing a reply to this topic", "fallbacks to English translations"); equal(I18n.t("hello.world"), "Hello World!", "doesn't break if a key is overriden in a locale"); + equal(I18n.t("hello.universe"), "", "allows empty strings"); }); test("extra translations", function() {