From 41a9c4183e61f3da2c64f3af8dcbe490d641e3b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Thu, 24 Oct 2024 23:56:05 +0200 Subject: [PATCH] pl-api: Make translation provider field optional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- packages/pl-api/lib/entities/translation.ts | 3 +-- packages/pl-fe/src/components/translate-button.tsx | 9 ++++++++- packages/pl-fe/src/locales/en.json | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/pl-api/lib/entities/translation.ts b/packages/pl-api/lib/entities/translation.ts index ed2727841..4ecc043a6 100644 --- a/packages/pl-api/lib/entities/translation.ts +++ b/packages/pl-api/lib/entities/translation.ts @@ -25,7 +25,6 @@ const translationSchema = v.pipe( if (translation?.text) return { content: translation.text, detected_source_language: translation.detected_language, - provider: '', }; return translation; @@ -37,7 +36,7 @@ const translationSchema = v.pipe( poll: v.fallback(v.optional(translationPollSchema), undefined), media_attachments: filteredArray(translationMediaAttachment), detected_source_language: v.string(), - provider: v.string(), + provider: v.fallback(v.nullable(v.string()), null), }), ); diff --git a/packages/pl-fe/src/components/translate-button.tsx b/packages/pl-fe/src/components/translate-button.tsx index 66181f614..f91a306c7 100644 --- a/packages/pl-fe/src/components/translate-button.tsx +++ b/packages/pl-fe/src/components/translate-button.tsx @@ -87,7 +87,14 @@ const TranslateButton: React.FC = ({ status }) => { {button} - + : undefined, + }} + /> ); diff --git a/packages/pl-fe/src/locales/en.json b/packages/pl-fe/src/locales/en.json index 35cd9cd4b..8ba99c5cd 100644 --- a/packages/pl-fe/src/locales/en.json +++ b/packages/pl-fe/src/locales/en.json @@ -1499,7 +1499,8 @@ "status.title": "Post details", "status.title_direct": "Direct message", "status.translate": "Translate", - "status.translated_from_with": "Translated from {lang} using {provider}", + "status.translated_from_with": "Translated from {lang} {provider}", + "status.translated_from_with.provider": "with {provider}", "status.translating": "Translating…", "status.unbookmark": "Remove bookmark", "status.unbookmarked": "Bookmark removed.",