From fe10350d0c16eb700e22960c34c25c4d8b50d94f Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Wed, 14 Oct 2009 11:26:26 +0000 Subject: Pluralization correct, off by one error in import git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@267 119bf307-c92d-0410-89bd-8f53e6181181 --- chrome/content/code/settings.xul.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'chrome/content') diff --git a/chrome/content/code/settings.xul.js b/chrome/content/code/settings.xul.js index 3efe061..c7b375c 100644 --- a/chrome/content/code/settings.xul.js +++ b/chrome/content/code/settings.xul.js @@ -41,6 +41,10 @@ var Settings = { this.addItemsToListBox(Redirector.list); this.strings = document.getElementById('redirector-strings'); + this.strings.getPluralized = function(id, number) { + id += number == 1 ? 'Singular' : ''; + return this.getFormattedString(id, [number]); + }; } catch(e) { alert(e); } @@ -230,13 +234,17 @@ var Settings = { return Redirector.importRedirects(file); }); - var msg; - if (result.imported > 0 && result.existed == 0) { - msg = this.strings.getFormattedString('importedMessage', [result.imported]); - } else if (result.imported > 0 && result.existed > 0) { - msg = this.strings.getFormattedString('importedAndExistedMessage', [result.imported, result.existed]); + var msg + + if (result.imported > 0) { + msg = this.strings.getPluralized('importedMessage', result.imported); + if (result.existed > 0) { + msg += ', ' + this.strings.getPluralized('existedMessage',result.existed); + } else { + msg += '.'; + } } else if (result.imported == 0 && result.existed > 0) { - msg = this.strings.getFormattedString('importedNoneAllExisted', [result.existed]); + msg = this.strings.getPluralized('allExistedMessage', result.existed); } else { //Both 0 msg = this.strings.getString('importedNone'); } -- cgit v1.2.3-70-g09d2