From f711dbc0113130dbf2e580e60dc9c047d48606ce Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sat, 15 Sep 2018 20:59:56 +0200 Subject: [PATCH] Improve plural support for the matches counter --- l10n/en-US/viewer.properties | 25 ++++++++++++++++--------- l10n/nl/viewer.properties | 25 ++++++++++++++++--------- l10n/sv-SE/viewer.properties | 25 ++++++++++++++++--------- web/pdf_find_bar.js | 24 +++++++++++------------- 4 files changed, 59 insertions(+), 40 deletions(-) diff --git a/l10n/en-US/viewer.properties b/l10n/en-US/viewer.properties index efeea6570..22045e111 100644 --- a/l10n/en-US/viewer.properties +++ b/l10n/en-US/viewer.properties @@ -168,20 +168,27 @@ find_match_case_label=Match case find_entire_word_label=Whole words find_reached_top=Reached top of document, continued from bottom find_reached_bottom=Reached end of document, continued from top -# LOCALIZATION NOTE (find_matches_count): The supported plural forms are -# [zero|one|two|few|many|other], with [other] as the default value. +# LOCALIZATION NOTE (find_match_count): The supported plural forms are +# [one|two|few|many|other], with [other] as the default value. # "{{current}}" and "{{total}}" will be replaced by a number representing the # index of the currently active find result, respectively a number representing # the total number of matches in the document. -find_matches_count={[ plural(n) ]} -find_matches_count[one]={{current}} of {{total}} match -find_matches_count[other]={{current}} of {{total}} matches -# LOCALIZATION NOTE (find_matches_count_limit): The supported plural forms are +find_match_count={[ plural(total) ]} +find_match_count[one]={{current}} of {{total}} match +find_match_count[two]={{current}} of {{total}} matches +find_match_count[few]={{current}} of {{total}} matches +find_match_count[many]={{current}} of {{total}} matches +find_match_count[other]={{current}} of {{total}} matches +# LOCALIZATION NOTE (find_match_count_limit): The supported plural forms are # [zero|one|two|few|many|other], with [other] as the default value. # "{{limit}}" will be replaced by a numerical value. -find_matches_count_limit={[ plural(n) ]} -find_matches_count_limit[one]=More than {{limit}} match -find_matches_count_limit[other]=More than {{limit}} matches +find_match_count_limit={[ plural(limit) ]} +find_match_count_limit[zero]=More than {{limit}} matches +find_match_count_limit[one]=More than {{limit}} match +find_match_count_limit[two]=More than {{limit}} matches +find_match_count_limit[few]=More than {{limit}} matches +find_match_count_limit[many]=More than {{limit}} matches +find_match_count_limit[other]=More than {{limit}} matches find_not_found=Phrase not found # Error panel labels diff --git a/l10n/nl/viewer.properties b/l10n/nl/viewer.properties index 40be77666..7422f8492 100644 --- a/l10n/nl/viewer.properties +++ b/l10n/nl/viewer.properties @@ -168,20 +168,27 @@ find_match_case_label=Hoofdlettergevoelig find_entire_word_label=Hele woorden find_reached_top=Bovenkant van document bereikt, doorgegaan vanaf onderkant find_reached_bottom=Onderkant van document bereikt, doorgegaan vanaf bovenkant -# LOCALIZATION NOTE (find_matches_count): The supported plural forms are -# [zero|one|two|few|many|other], with [other] as the default value. +# LOCALIZATION NOTE (find_match_count): The supported plural forms are +# [one|two|few|many|other], with [other] as the default value. # "{{current}}" and "{{total}}" will be replaced by a number representing the # index of the currently active find result, respectively a number representing # the total number of matches in the document. -find_matches_count={[ plural(n) ]} -find_matches_count[one]={{current}} van {{total}} overeenkomst -find_matches_count[other]={{current}} van {{total}} overeenkomsten -# LOCALIZATION NOTE (find_matches_count_limit): The supported plural forms are +find_match_count={[ plural(total) ]} +find_match_count[one]={{current}} van {{total}} overeenkomst +find_match_count[two]={{current}} van {{total}} overeenkomsten +find_match_count[few]={{current}} van {{total}} overeenkomsten +find_match_count[many]={{current}} van {{total}} overeenkomsten +find_match_count[other]={{current}} van {{total}} overeenkomsten +# LOCALIZATION NOTE (find_match_count_limit): The supported plural forms are # [zero|one|two|few|many|other], with [other] as the default value. # "{{limit}}" will be replaced by a numerical value. -find_matches_count_limit={[ plural(n) ]} -find_matches_count_limit[one]=Meer dan {{limit}} overeenkomst -find_matches_count_limit[other]=Meer dan {{limit}} overeenkomsten +find_match_count_limit={[ plural(limit) ]} +find_match_count_limit[zero]=Meer dan {{limit}} overeenkomsten +find_match_count_limit[one]=Meer dan {{limit}} overeenkomst +find_match_count_limit[two]=Meer dan {{limit}} overeenkomsten +find_match_count_limit[few]=Meer dan {{limit}} overeenkomsten +find_match_count_limit[many]=Meer dan {{limit}} overeenkomsten +find_match_count_limit[other]=Meer dan {{limit}} overeenkomsten find_not_found=Tekst niet gevonden # Error panel labels diff --git a/l10n/sv-SE/viewer.properties b/l10n/sv-SE/viewer.properties index 754f2a5d0..7f329ca91 100644 --- a/l10n/sv-SE/viewer.properties +++ b/l10n/sv-SE/viewer.properties @@ -168,20 +168,27 @@ find_match_case_label=Matcha versal/gemen find_entire_word_label=Hela ord find_reached_top=Nådde början av dokumentet, började från slutet find_reached_bottom=Nådde slutet på dokumentet, började från början -# LOCALIZATION NOTE (find_matches_count): The supported plural forms are -# [zero|one|two|few|many|other], with [other] as the default value. +# LOCALIZATION NOTE (find_match_count): The supported plural forms are +# [one|two|few|many|other], with [other] as the default value. # "{{current}}" and "{{total}}" will be replaced by a number representing the # index of the currently active find result, respectively a number representing # the total number of matches in the document. -find_matches_count={[ plural(n) ]} -find_matches_count[one]={{current}} av {{total}} matchningar -find_matches_count[other]={{current}} av {{total}} matchande -# LOCALIZATION NOTE (find_matches_count_limit): The supported plural forms are +find_match_count={[ plural(total) ]} +find_match_count[one]={{current}} av {{total}} matchningar +find_match_count[two]={{current}} av {{total}} matchande +find_match_count[few]={{current}} av {{total}} matchande +find_match_count[many]={{current}} av {{total}} matchande +find_match_count[other]={{current}} av {{total}} matchande +# LOCALIZATION NOTE (find_match_count_limit): The supported plural forms are # [zero|one|two|few|many|other], with [other] as the default value. # "{{limit}}" will be replaced by a numerical value. -find_matches_count_limit={[ plural(n) ]} -find_matches_count_limit[one]=Fler än {{limit}} matchning -find_matches_count_limit[other]=Fler än {{limit}} matchningar +find_match_count_limit={[ plural(limit) ]} +find_match_count_limit[zero]=Fler än {{limit}} matchningar +find_match_count_limit[one]=Fler än {{limit}} matchning +find_match_count_limit[two]=Fler än {{limit}} matchningar +find_match_count_limit[few]=Fler än {{limit}} matchningar +find_match_count_limit[many]=Fler än {{limit}} matchningar +find_match_count_limit[other]=Fler än {{limit}} matchningar find_not_found=Frasen hittades inte # Error panel labels diff --git a/web/pdf_find_bar.js b/web/pdf_find_bar.js index 5cd07710c..310acd2bb 100644 --- a/web/pdf_find_bar.js +++ b/web/pdf_find_bar.js @@ -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' : '')); } }