1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Improve plural support for the matches counter

This commit is contained in:
Tim van der Meij 2018-09-15 20:59:56 +02:00
parent a85ee3616e
commit f711dbc011
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
4 changed files with 59 additions and 40 deletions

View file

@ -159,33 +159,31 @@ class PDFFindBar {
}
let matchesCountMsg = '', limit = MATCHES_COUNT_LIMIT;
if (total) {
if (total > 0) {
if (total > limit) {
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) {
// TODO: Remove this hard-coded `[other]` form once plural support has
// been implemented in the mozilla-central specific `l10n.js` file.
matchesCountMsg = this.l10n.get('find_matches_count_limit[other]', {
limit: limit.toLocaleString(),
matchesCountMsg = this.l10n.get('find_match_count_limit[other]', {
limit,
}, 'More than {{limit}} matches');
} else {
matchesCountMsg = this.l10n.get('find_matches_count_limit', {
n: limit,
limit: limit.toLocaleString(),
matchesCountMsg = this.l10n.get('find_match_count_limit', {
limit,
}, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
}
} else {
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) {
// TODO: Remove this hard-coded `[other]` form once plural support has
// been implemented in the mozilla-central specific `l10n.js` file.
matchesCountMsg = this.l10n.get('find_matches_count[other]', {
current: current.toLocaleString(),
total: total.toLocaleString(),
matchesCountMsg = this.l10n.get('find_match_count[other]', {
current,
total,
}, '{{current}} of {{total}} matches');
} else {
matchesCountMsg = this.l10n.get('find_matches_count', {
n: total,
current: current.toLocaleString(),
total: total.toLocaleString(),
matchesCountMsg = this.l10n.get('find_match_count', {
current,
total,
}, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
}
}