diff --git a/browser/components/loop/content/libs/l10n.js b/browser/components/loop/content/libs/l10n.js index 8429fcfaaff0..f33bac91cbbf 100644 --- a/browser/components/loop/content/libs/l10n.js +++ b/browser/components/loop/content/libs/l10n.js @@ -38,8 +38,9 @@ // translate a string function translateString(key, args, fallback) { - if (args && args.num) { - var num = args && args.num; + var num; + if (args && ("num" in args)) { + num = args.num; } var data = getL10nData(key, num); if (!data && fallback) diff --git a/browser/components/loop/test/desktop-local/l10n_test.js b/browser/components/loop/test/desktop-local/l10n_test.js index f76b0a19773e..0f15dbacd0bb 100644 --- a/browser/components/loop/test/desktop-local/l10n_test.js +++ b/browser/components/loop/test/desktop-local/l10n_test.js @@ -34,4 +34,8 @@ describe("document.mozL10n", function() { it("should get a plural form", function() { expect(document.mozL10n.get("plural", {num: 10})).eql("10 plural forms"); }); + + it("should correctly get a plural form for num = 0", function() { + expect(document.mozL10n.get("plural", {num: 0})).eql("0 plural form"); + }); });