Fix PluralForm support

The library was using the plural rule defined in the built-in
intl.properties, but that was always en-US in the standalone app.
This commit is contained in:
Dan Stillman 2017-07-25 15:20:23 -04:00
parent c2234176aa
commit 521f291b84
46 changed files with 60 additions and 15 deletions

View file

@ -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"]
@ -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);
}
}
}

View file

@ -1 +1,2 @@
general.useragent.locale=af-ZA
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=ar
pluralRule=12

View file

@ -1 +1,2 @@
general.useragent.locale=bg-BG
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=ca-AD
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=cs-CZ
pluralRule=8

View file

@ -1 +1,2 @@
general.useragent.locale=da-DK
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=de
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=el-GR
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=en-US
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=es-ES
general.useragent.locale =es-ES
pluralRule = 1

View file

@ -1 +1,2 @@
general.useragent.locale=et-EE
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=eu-ES
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=fa
pluralRule=0

View file

@ -1 +1,2 @@
general.useragent.locale=fi-FI
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=fr-FR
pluralRule=2

View file

@ -1 +1,2 @@
general.useragent.locale=gl-ES
general.useragent.locale=en-US
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=he-IL
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=hr-HR
pluralRule=7

View file

@ -1 +1,2 @@
general.useragent.locale=hu-HU
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=id-ID
pluralRule=0

View file

@ -1 +1,2 @@
general.useragent.locale=is-IS
pluralRule=15

View file

@ -1 +1,2 @@
general.useragent.locale=it-IT
general.useragent.locale =it-IT
pluralRule = 1

View file

@ -1 +1,2 @@
general.useragent.locale=ja-JP
general.useragent.locale =ja-JP
pluralRule = 0

View file

@ -1 +1,2 @@
general.useragent.locale=km
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=ko-KR
pluralRule=0

View file

@ -1 +1,2 @@
general.useragent.locale=lt-LT
pluralRule=6

View file

@ -1 +1,2 @@
general.useragent.locale=mn-MN
general.useragent.locale=en-US
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=nb-NO
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=nl-NL
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=nn-NO
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=pl-PL
pluralRule=9

View file

@ -1 +1,2 @@
general.useragent.locale=pt-BR
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=pt-PT
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=ro-RO
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=ru-RU
general.useragent.locale =ru-RU
pluralRule = 7

View file

@ -1 +1,2 @@
general.useragent.locale=sk-SK
pluralRule=8

View file

@ -1 +1,2 @@
general.useragent.locale=sl-SI
pluralRule=10

View file

@ -1 +1,2 @@
general.useragent.locale=sr-RS
pluralRule=7

View file

@ -1 +1,2 @@
general.useragent.locale=sv-SE
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=th-TH
pluralRule=0

View file

@ -1 +1,2 @@
general.useragent.locale=tr-TR
pluralRule=0

View file

@ -1 +1,2 @@
general.useragent.locale=uk-UA
pluralRule=7

View file

@ -1 +1,2 @@
general.useragent.locale=vi-VN
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=zh-CN
pluralRule=1

View file

@ -1 +1,2 @@
general.useragent.locale=zh-TW
pluralRule=0