Skip to content

Commit

Permalink
Merge pull request #1191 from nextcloud-libraries/fix/improve-choose-…
Browse files Browse the repository at this point in the history
…button

fix(FilePicker): Improve choose button text when selecting multiple
  • Loading branch information
susnux committed Jan 18, 2024
2 parents 3d844cc + 76fe2ae commit 5d73c78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions l10n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

Expand Down
10 changes: 8 additions & 2 deletions lib/filepicker-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -209,10 +209,16 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
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) {
Expand Down

0 comments on commit 5d73c78

Please sign in to comment.