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

Attempt to support plural forms in the matches counter of the findbar (issue 10067)

Based on a quick look at https://github.com/fabi1cazenave/webL10n/#pluralization, it seems that supporting plural forms shouldn't be as difficult as I first thought it might be.
This commit is contained in:
Jonas Jenwald 2018-09-13 10:12:58 +02:00
parent 6adeabbb66
commit 6c4157acd9
4 changed files with 49 additions and 26 deletions

View file

@ -157,18 +157,20 @@ class PDFFindBar {
if (!this.findResultsCount) {
return; // No UI control is provided.
}
let matchesCountMsg = '';
let matchesCountMsg = '', limit = MATCHES_COUNT_LIMIT;
if (total) {
if (total > MATCHES_COUNT_LIMIT) {
if (total > limit) {
matchesCountMsg = this.l10n.get('find_matches_count_limit', {
limit: MATCHES_COUNT_LIMIT.toLocaleString(),
}, 'More than {{limit}} matches');
n: limit,
limit: limit.toLocaleString(),
}, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
} else {
matchesCountMsg = this.l10n.get('find_matches_count', {
n: total,
current: current.toLocaleString(),
total: total.toLocaleString(),
}, '{{current}} of {{total}} matches');
}, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
}
}
Promise.resolve(matchesCountMsg).then((msg) => {