diff --git a/public/locales/en.json b/public/locales/en.json index 93ece585..a4cea328 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -81,10 +81,8 @@ "confirmation_other": "You are about to download {{count}} chapters.\nSuwayomi is not a mass downloader and too many downloads can get you banned from sources and/or cause performance issues.", "error_one": "Could not add the download", "error_other": "Could not add downloads", - "next": "$t(reader.button.next_chapter)", - "next_five": "Next 5 chapters", - "next_ten": "Next 10 chapters", - "next_twentyfive": "Next 25 chapters", + "next_one": "Next chapter", + "next_other" : "Next {{count}} chapters", "success_one": "Download added", "success_other": "{{count}} downloads added", "unread": "$t(global.filter.label.unread)" diff --git a/src/modules/chapter/components/actions/ChaptersDownloadActionMenuItems.tsx b/src/modules/chapter/components/actions/ChaptersDownloadActionMenuItems.tsx index f6bc4ec5..894f9f4c 100644 --- a/src/modules/chapter/components/actions/ChaptersDownloadActionMenuItems.tsx +++ b/src/modules/chapter/components/actions/ChaptersDownloadActionMenuItems.tsx @@ -12,14 +12,25 @@ import { useMetadataServerSettings } from '@/modules/settings/services/ServerSet import { Mangas } from '@/modules/manga/services/Mangas.ts'; import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts'; import { MangaType } from '@/lib/graphql/generated/graphql.ts'; +import { TranslationKey } from '@/Base.types.ts'; -const DownloadRange = { - NEXT_1: 1, - NEXT_5: 5, - NEXT_10: 10, - NEXT_25: 25, - ALL: undefined, -}; +const DOWNLOAD_OPTIONS: { + title: TranslationKey; + getCount: (downloadAheadLimit: number) => number | undefined; + onlyUnread?: boolean; +}[] = [ + { title: 'chapter.action.download.add.label.next', getCount: () => 1 }, + { title: 'chapter.action.download.add.label.next', getCount: () => 5 }, + { title: 'chapter.action.download.add.label.next', getCount: () => 10 }, + { title: 'chapter.action.download.add.label.next', getCount: () => 25 }, + { + title: 'chapter.action.download.add.label.ahead', + getCount: (downloadAheadLimit) => downloadAheadLimit, + onlyUnread: true, + }, + { title: 'chapter.action.download.add.label.unread', getCount: () => undefined, onlyUnread: true }, + { title: 'chapter.action.download.add.label.all', getCount: () => undefined, onlyUnread: false }, +]; export const ChaptersDownloadActionMenuItems = ({ mangaIds, @@ -39,33 +50,20 @@ export const ChaptersDownloadActionMenuItems = ({ downloadAhead, onlyUnread, size, - }).catch(defaultPromiseErrorHandler('ChapterDownloadButton::handleSelect')); + }).catch(defaultPromiseErrorHandler('ChaptersDownloadActionMenuItems::handleSelect')); closeMenu?.(); }; return ( <> - handleSelect(DownloadRange.NEXT_1)}> - {t('chapter.action.download.add.label.next')} - - handleSelect(DownloadRange.NEXT_5)}> - {t('chapter.action.download.add.label.next_five')} - - handleSelect(DownloadRange.NEXT_10)}> - {t('chapter.action.download.add.label.next_ten')} - - handleSelect(DownloadRange.NEXT_25)}> - {t('chapter.action.download.add.label.next_twentyfive')} - - handleSelect(downloadAheadLimit, undefined, true)}> - {t('chapter.action.download.add.label.ahead', { count: downloadAheadLimit })} - - handleSelect(DownloadRange.ALL, true)}> - {t('chapter.action.download.add.label.unread')} - - handleSelect(DownloadRange.ALL, false)}> - {t('chapter.action.download.add.label.all')} - + {DOWNLOAD_OPTIONS.map(({ title, getCount, onlyUnread }) => ( + handleSelect(getCount(downloadAheadLimit), onlyUnread)} + > + {t(title, { count: getCount(downloadAheadLimit) })} + + ))} ); };