From 76fe2ae057ee44359ed7894d3f39b71b6582e78a Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 18 Jan 2024 01:52:18 +0100 Subject: [PATCH] fix(FilePicker): Improve choose button text when selecting multiple Signed-off-by: Ferdinand Thiessen --- l10n/messages.pot | 5 +++++ lib/filepicker-builder.ts | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/l10n/messages.pot b/l10n/messages.pot index b8d6d1b6..9b73f1f6 100644 --- a/l10n/messages.pot +++ b/l10n/messages.pot @@ -20,6 +20,11 @@ msgstr "" msgid "Choose {file}" msgstr "" +msgid "Choose %n file" +msgid_plural "Choose %n files" +msgstr[0] "" +msgstr[1] "" + msgid "Copy" msgstr "" diff --git a/lib/filepicker-builder.ts b/lib/filepicker-builder.ts index a5a8f85f..e3ccdd53 100644 --- a/lib/filepicker-builder.ts +++ b/lib/filepicker-builder.ts @@ -25,7 +25,7 @@ import type { Node } from '@nextcloud/files' import { basename } from 'path' import { spawnDialog } from './utils/dialogs' -import { t } from './utils/l10n' +import { n, t } from './utils/l10n' import IconMove from '@mdi/svg/svg/folder-move.svg?raw' import IconCopy from '@mdi/svg/svg/folder-multiple.svg?raw' @@ -209,10 +209,16 @@ export class FilePickerBuilder { const target = node || basename(path) if (type === FilePickerType.Choose) { + let label = t('Choose') + if (nodes.length === 1) { + label = t('Choose {file}', { file: node }) + } else if (this.multiSelect) { + label = n('Choose %n file', 'Choose %n files', nodes.length) + } buttons.push({ callback: () => {}, - label: node && !this.multiSelect ? t('Choose {file}', { file: node }) : t('Choose'), type: 'primary', + label, }) } if (type === FilePickerType.CopyMove || type === FilePickerType.Copy) {