Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions apps/files/src/actions/convertUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { OCSResponse } from '@nextcloud/typings/ocs'
import { emit } from '@nextcloud/event-bus'
import { generateOcsUrl } from '@nextcloud/router'
import { showError, showLoading, showSuccess } from '@nextcloud/dialogs'
import { t } from '@nextcloud/l10n'
import { n, t } from '@nextcloud/l10n'
import axios, { isAxiosError } from '@nextcloud/axios'
import PQueue from 'p-queue'

Expand All @@ -21,8 +21,8 @@ type ConversionResponse = {
}

interface PromiseRejectedResult<T> {
status: 'rejected'
reason: T
status: 'rejected'
reason: T
}

type PromiseSettledResult<T, E> = PromiseFulfilledResult<T> | PromiseRejectedResult<E>;
Expand Down Expand Up @@ -62,23 +62,16 @@ export const convertFiles = async function(fileIds: number[], targetMimeType: st
return
}

// A single file failed
if (failed.length === 1) {
// If we have a message for the failed file, show it
if (messages[0]) {
showError(t('files', 'One file could not be converted: {message}', { message: messages[0] }))
return
}

// Otherwise, show a generic error
showError(t('files', 'One file could not be converted'))
// A single file failed and if we have a message for the failed file, show it
if (failed.length === 1 && messages[0]) {
showError(t('files', 'One file could not be converted: {message}', { message: messages[0] }))
return
}

// We already check above when all files failed
// if we're here, we have a mix of failed and successful files
showError(t('files', '{count} files could not be converted', { count: failed.length }))
showSuccess(t('files', '{count} files successfully converted', { count: fileIds.length - failed.length }))
showError(n('files', 'One file could not be converted', '%n files could not be converted', failed.length))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the placeholder also in singular (even if you split the === 1 case of above) to keep it more logical for translators of languages where they have no "plural" for 1, but e.g. the first plural rule is for numbers 1-3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be already done on master not only on the backport

showSuccess(n('files', 'One file successfully converted', '%n files successfully converted', fileIds.length - failed.length))
return
}

Expand Down
4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

Loading