fix: say "1 email selected" in the tag picker header

This commit is contained in:
Linus Rath
2026-10-31 13:47:05 +01:00
parent d6b9b342e9
commit 9ce89e2672
4 changed files with 29 additions and 1 deletions
+1
View File
@@ -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"
+1
View File
@@ -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"
+3 -1
View File
@@ -87,7 +87,9 @@ export function TagSheet({ visible, onClose, keywords, selectedEmails, onToggle
</View>
<View style={styles.header}>
<Text style={styles.title}>
{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 })}
</Text>
<Pressable onPress={onClose} hitSlop={10} style={styles.close}
accessibilityRole="button"
@@ -0,0 +1,24 @@
// The tag picker's header read "1 emails selected": it used the webmail's
// context_menu.items_selected ("{count} emails selected"), which has no
// singular since the webmail shows it for several emails only.
import { describe, expect, it, vi } from 'vitest';
import fs from 'node:fs';
import path from 'node:path';
vi.mock('expo-localization', () => ({ 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');
});
});