Skip to content

Commit

Permalink
Fix PluralForm support
Browse files Browse the repository at this point in the history
The library was using the plural rule defined in the built-in
intl.properties, but that was always en-US in the standalone app.
  • Loading branch information
dstillman committed Jul 25, 2017
1 parent c223417 commit 521f291
Show file tree
Hide file tree
Showing 46 changed files with 60 additions and 15 deletions.
18 changes: 9 additions & 9 deletions chrome/content/zotero/xpcom/zotero.js
Expand Up @@ -225,18 +225,18 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
Zotero.browser = "g";

// Get resolved locale
this.locale = Services.strings.createBundle("chrome://zotero/locale/mozilla/intl.properties")
.GetStringFromName("general.useragent.locale");

_localizedStringBundle = Services.strings.createBundle("chrome://zotero/locale/zotero.properties");
// Fix logged error in PluralForm.jsm when numForms() is called before get(), as it is in
// getString() when a number is based
PluralForm.get(1, '1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16')
var intlProps = Services.strings.createBundle("chrome://zotero/locale/mozilla/intl.properties");
this.locale = intlProps.GetStringFromName("general.useragent.locale");
let [get, numForms] = PluralForm.makeGetter(intlProps.GetStringFromName("pluralRule"));
this.pluralFormGet = get;
this.pluralFormNumForms = numForms;

// Also load the brand as appName
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
this.appName = brandBundle.GetStringFromName("brandShortName");

_localizedStringBundle = Services.strings.createBundle("chrome://zotero/locale/zotero.properties");

// Set the locale direction to Zotero.dir
// DEBUG: is there a better way to get the entity from JS?
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
Expand Down Expand Up @@ -1239,11 +1239,11 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
// If not enough available forms, use last one -- PluralForm.get() uses first by
// default, but it's more likely that a localizer will translate the two English
// strings with some plural form as the second one, so we might as well use that
if (availableForms.length < PluralForm.numForms()) {
if (availableForms.length < this.pluralFormNumForms()) {
l10n = availableForms[availableForms.length - 1];
}
else {
l10n = PluralForm.get(num, l10n);
l10n = this.pluralFormGet(num, l10n);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions chrome/locale/af-ZA/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=af-ZA
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/ar/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=ar
pluralRule=12
1 change: 1 addition & 0 deletions chrome/locale/bg-BG/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=bg-BG
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/ca-AD/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=ca-AD
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/cs-CZ/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=cs-CZ
pluralRule=8
1 change: 1 addition & 0 deletions chrome/locale/da-DK/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=da-DK
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/de/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=de
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/el-GR/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=el-GR
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/en-US/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=en-US
pluralRule=1
3 changes: 2 additions & 1 deletion chrome/locale/es-ES/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=es-ES
general.useragent.locale =es-ES
pluralRule = 1
1 change: 1 addition & 0 deletions chrome/locale/et-EE/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=et-EE
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/eu-ES/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=eu-ES
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/fa/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=fa
pluralRule=0
1 change: 1 addition & 0 deletions chrome/locale/fi-FI/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=fi-FI
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/fr-FR/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=fr-FR
pluralRule=2
3 changes: 2 additions & 1 deletion chrome/locale/gl-ES/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=gl-ES
general.useragent.locale=en-US
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/he-IL/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=he-IL
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/hr-HR/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=hr-HR
pluralRule=7
1 change: 1 addition & 0 deletions chrome/locale/hu-HU/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=hu-HU
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/id-ID/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=id-ID
pluralRule=0
1 change: 1 addition & 0 deletions chrome/locale/is-IS/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=is-IS
pluralRule=15
3 changes: 2 additions & 1 deletion chrome/locale/it-IT/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=it-IT
general.useragent.locale =it-IT
pluralRule = 1
3 changes: 2 additions & 1 deletion chrome/locale/ja-JP/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=ja-JP
general.useragent.locale =ja-JP
pluralRule = 0
1 change: 1 addition & 0 deletions chrome/locale/km/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=km
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/ko-KR/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=ko-KR
pluralRule=0
1 change: 1 addition & 0 deletions chrome/locale/lt-LT/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=lt-LT
pluralRule=6
3 changes: 2 additions & 1 deletion chrome/locale/mn-MN/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=mn-MN
general.useragent.locale=en-US
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/nb-NO/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=nb-NO
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/nl-NL/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=nl-NL
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/nn-NO/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=nn-NO
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/pl-PL/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=pl-PL
pluralRule=9
1 change: 1 addition & 0 deletions chrome/locale/pt-BR/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=pt-BR
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/pt-PT/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=pt-PT
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/ro-RO/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=ro-RO
pluralRule=1
3 changes: 2 additions & 1 deletion chrome/locale/ru-RU/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=ru-RU
general.useragent.locale =ru-RU
pluralRule = 7
1 change: 1 addition & 0 deletions chrome/locale/sk-SK/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=sk-SK
pluralRule=8
1 change: 1 addition & 0 deletions chrome/locale/sl-SI/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=sl-SI
pluralRule=10
1 change: 1 addition & 0 deletions chrome/locale/sr-RS/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=sr-RS
pluralRule=7
1 change: 1 addition & 0 deletions chrome/locale/sv-SE/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=sv-SE
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/th-TH/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=th-TH
pluralRule=0
1 change: 1 addition & 0 deletions chrome/locale/tr-TR/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=tr-TR
pluralRule=0
1 change: 1 addition & 0 deletions chrome/locale/uk-UA/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=uk-UA
pluralRule=7
1 change: 1 addition & 0 deletions chrome/locale/vi-VN/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=vi-VN
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/zh-CN/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=zh-CN
pluralRule=1
1 change: 1 addition & 0 deletions chrome/locale/zh-TW/zotero/mozilla/intl.properties
@@ -1 +1,2 @@
general.useragent.locale=zh-TW
pluralRule=0

0 comments on commit 521f291

Please sign in to comment.