From 79fe064c4a313d11d95f2b4ff70af15949cce21c Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Sat, 19 Apr 2025 23:25:17 -0700 Subject: [PATCH] Add: server localization for chapter lookup --- client/pages/audiobook/_id/chapters.vue | 2 +- client/strings/en-us.json | 2 ++ server/controllers/SearchController.js | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue index da33eba0..55f74b5c 100644 --- a/client/pages/audiobook/_id/chapters.vue +++ b/client/pages/audiobook/_id/chapters.vue @@ -565,7 +565,7 @@ export default { this.findingChapters = false if (data.error) { - this.asinError = data.error + this.asinError = this.$getString(data.stringKey) } else { console.log('Chapter data', data) this.chapterData = data diff --git a/client/strings/en-us.json b/client/strings/en-us.json index 94bb9f55..2bf70b53 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -724,6 +724,7 @@ "MessageChapterErrorStartGteDuration": "Invalid start time must be less than audiobook duration", "MessageChapterErrorStartLtPrev": "Invalid start time must be greater than or equal to previous chapter start time", "MessageChapterStartIsAfter": "Chapter start is after the end of your audiobook", + "MessageChaptersNotFound": "Chapters not found", "MessageCheckingCron": "Checking cron...", "MessageConfirmCloseFeed": "Are you sure you want to close this feed?", "MessageConfirmDeleteBackup": "Are you sure you want to delete backup for {0}?", @@ -780,6 +781,7 @@ "MessageForceReScanDescription": "will scan all files again like a fresh scan. Audio file ID3 tags, OPF files, and text files will be scanned as new.", "MessageImportantNotice": "Important Notice!", "MessageInsertChapterBelow": "Insert chapter below", + "MessageInvalidAsin": "Invalid ASIN", "MessageItemsSelected": "{0} items selected", "MessageItemsUpdated": "{0} items updated", "MessageJoinUsOn": "Join us on", diff --git a/server/controllers/SearchController.js b/server/controllers/SearchController.js index 51aaa910..bb3382f7 100644 --- a/server/controllers/SearchController.js +++ b/server/controllers/SearchController.js @@ -108,12 +108,12 @@ class SearchController { async findChapters(req, res) { const asin = req.query.asin if (!isValidASIN(asin.toUpperCase())) { - return res.json({ error: 'Invalid ASIN' }) + return res.json({ error: 'Invalid ASIN', stringKey: 'MessageInvalidAsin' }) } const region = (req.query.region || 'us').toLowerCase() const chapterData = await BookFinder.findChapters(asin, region) if (!chapterData) { - return res.json({ error: 'Chapters not found' }) + return res.json({ error: 'Chapters not found', stringKey: 'MessageChaptersNotFound' }) } res.json(chapterData) }