From 9ce89e2672bcaab41d9bc99d07a188d27ad658b4 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sat, 31 Oct 2026 13:47:05 +0100 Subject: [PATCH] fix: say "1 email selected" in the tag picker header --- locales/rn/de.json | 1 + locales/rn/en.json | 1 + src/components/TagSheet.tsx | 4 +++- .../__tests__/tag-sheet-title.test.ts | 24 +++++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/components/__tests__/tag-sheet-title.test.ts diff --git a/locales/rn/de.json b/locales/rn/de.json index 3046e3c4..d330d520 100644 --- a/locales/rn/de.json +++ b/locales/rn/de.json @@ -273,6 +273,7 @@ }, "context_menu": { "color_tag": "Label", + "emails_selected": "{count, plural, one {# E-Mail ausgewählt} other {# E-Mails ausgewählt}}", "remove_color": "Label entfernen", "rules": { "login_changed": "Sie haben das Konto gewechselt, daher wurde die Regel nicht gespeichert" diff --git a/locales/rn/en.json b/locales/rn/en.json index b9ff4a2b..c853df06 100644 --- a/locales/rn/en.json +++ b/locales/rn/en.json @@ -317,6 +317,7 @@ }, "context_menu": { "color_tag": "Tag", + "emails_selected": "{count, plural, one {# email selected} other {# emails selected}}", "remove_color": "Remove tag", "rules": { "login_changed": "You switched accounts, so the rule was not saved" diff --git a/src/components/TagSheet.tsx b/src/components/TagSheet.tsx index ebd3ad7b..8e6426f3 100644 --- a/src/components/TagSheet.tsx +++ b/src/components/TagSheet.tsx @@ -87,7 +87,9 @@ export function TagSheet({ visible, onClose, keywords, selectedEmails, onToggle - {t('context_menu.items_selected', `${selectedEmails.length} emails selected`, { count: selectedEmails.length })} + {/* Not context_menu.items_selected: "{count} emails selected" has no + singular, and the sheet opens for one email too. */} + {t('context_menu.emails_selected', '{count, plural, one {# email selected} other {# emails selected}}', { count: selectedEmails.length })} ({ getLocales: () => [] })); + +import { translate } from '../../i18n'; + +const source = fs.readFileSync(path.resolve(__dirname, '../TagSheet.tsx'), 'utf8'); +// The key and, when it is a literal, the English fallback. +const call = /t\('(context_menu\.[a-z_]+)', (?:'([^']*)'|`[^`]*`), \{ count: selectedEmails\.length \}\)/.exec(source); + +describe('the tag picker header', () => { + it('counts the selection with a plural', () => { + expect(call).not.toBeNull(); + const [, key, fallback] = call!; + expect(translate('en', key, fallback, { count: 1 })).toBe('1 email selected'); + expect(translate('en', key, fallback, { count: 3 })).toBe('3 emails selected'); + expect(translate('de', key, fallback, { count: 1 })).toBe('1 E-Mail ausgewählt'); + }); +});