www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit b680bcf375a2afd73ca42b677ad458126aec0b45
parent 7f7d78603a3419a32eca8d6423dad96c22d3802a
Author: Aurimas Vinckevicius <aurimas.dev@gmail.com>
Date:   Tue, 17 Sep 2013 23:55:21 -0500

Abbreviate plural forms of words same as singular

Diffstat:
Mchrome/content/zotero/xpcom/cite.js | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js @@ -408,8 +408,9 @@ Zotero.Cite.getAbbreviation = new function() { for(var j=0; j<words.length; j+=2) { var word = words[j], lcWord = lookupKey(word), - newWord = undefined; - + newWord = undefined, + exactMatch = false; + for(var i=0; i<jurisdictions.length && newWord === undefined; i++) { if(!(jur = abbreviations[jurisdictions[i]])) continue; if(!(cat = jur[category+"-word"])) continue; @@ -417,6 +418,11 @@ Zotero.Cite.getAbbreviation = new function() { // Complete match if(cat.hasOwnProperty(lcWord)) { newWord = cat[lcWord]; + exactMatch = true; + } else if(lcWord.charAt(lcWord.length-1) == 's' && cat.hasOwnProperty(lcWord.substr(0, lcWord.length-1))) { + // Try dropping 's' + newWord = cat[lcWord.substr(0, lcWord.length-1)]; + exactMatch = true; } else { // Partial match for(var k=word.length; k>0 && newWord === undefined; k--) { @@ -426,7 +432,7 @@ Zotero.Cite.getAbbreviation = new function() { } // Don't substitute with a longer word - if(newWord && word.length - newWord.length < 1) { + if(newWord && !exactMatch && word.length - newWord.length < 1) { newWord = word; }