diff options
author | Caitlin Jordan <jordan.cait17@gmail.com> | 2025-02-25 10:08:53 -0800 |
---|---|---|
committer | skjnldsv <skjnldsv@protonmail.com> | 2025-03-12 09:02:55 +0100 |
commit | ee013b478901680a2e071eba8ef0610cf2afa5b4 (patch) | |
tree | a022e9e092e9e6e3a1cf671e9ed1bfc3e05a77ab /apps/files/src | |
parent | 6663676ca57d62554843dd7cdc0cd094689f3809 (diff) | |
download | nextcloud-server-ee013b478901680a2e071eba8ef0610cf2afa5b4.tar.gz nextcloud-server-ee013b478901680a2e071eba8ef0610cf2afa5b4.zip |
fix(files): correctly handle plural translation forms
Co-authored-by: Caitlin Jordan <jordan.cait17@gmail.com>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files/src')
-rw-r--r-- | apps/files/src/actions/convertUtils.ts | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/apps/files/src/actions/convertUtils.ts b/apps/files/src/actions/convertUtils.ts index 7e3cebd77a9..0ace3747d9c 100644 --- a/apps/files/src/actions/convertUtils.ts +++ b/apps/files/src/actions/convertUtils.ts @@ -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' @@ -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>; @@ -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)) + showSuccess(n('files', 'One file successfully converted', '%n files successfully converted', fileIds.length - failed.length)) return } |