From 3f851d662d2cc8a86f878d4c82aeeaa196049f1a Mon Sep 17 00:00:00 2001 From: velomovies <22169955+velomovies@users.noreply.github.com> Date: Fri, 1 Aug 2025 17:01:09 +0200 Subject: [PATCH 1/4] feat(helpers): add getFullLocaleText function --- src/entrypoints/FieldAddon/FieldAddon.tsx | 20 ++++++++++++-------- src/lib/helpers.test.ts | 21 +++++++++++++++++++++ src/lib/helpers.ts | 7 +++++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/entrypoints/FieldAddon/FieldAddon.tsx b/src/entrypoints/FieldAddon/FieldAddon.tsx index 731c403..105b8b1 100644 --- a/src/entrypoints/FieldAddon/FieldAddon.tsx +++ b/src/entrypoints/FieldAddon/FieldAddon.tsx @@ -31,7 +31,7 @@ import { translationFormats, translationServiceOptions, } from '../../lib/constants' -import { fieldHasFieldValue } from '../../lib/helpers' +import { fieldHasFieldValue, getFullLocaleText } from '../../lib/helpers' type Props = { ctx: RenderFieldExtensionCtx @@ -220,7 +220,9 @@ export default function FieldAddon({ ctx }: Props) { } } else { setHasError( - `Please add content to the default field (${fromLocale || locales[0]})`, + `Please add content to the ${ + fromLocale ? getFullLocaleText(fromLocale) : '' + } field`, ) } } @@ -269,20 +271,22 @@ export default function FieldAddon({ ctx }: Props) { } disabled={isTranslating} > - Copy and translate from {locales[0]} + Copy and translate from {getFullLocaleText(locales[0])} ) } + const otherLocales = locales.filter((locale) => locale !== currentLocale) + const buttonText = + locales.length > 2 + ? 'Translate to all locales' + : `Translate to ${getFullLocaleText(otherLocales[0])}` + return ( -
- translateField(locales.filter((locale) => locale !== currentLocale)) - } - > + translateField(otherLocales)}>
From 2b3d789958cb709fe4f2500e752cee6ccbd576c0 Mon Sep 17 00:00:00 2001 From: velomovies <22169955+velomovies@users.noreply.github.com> Date: Fri, 1 Aug 2025 17:02:25 +0200 Subject: [PATCH 4/4] feat(README.md): add setting for showing/hiding translate all button --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8922cda..71c5a02 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ For this plugin you can configure global settings and configure the plugin per f - **Auto apply to fields (switch)**: When enabled this will automatically apply the plugin to all `structured-text`, `rich-text`, `string`, `text` and `seo` fields. By changing the following setting you can choose on which fields this plugin will be applied. +- **Show "Translate to all locales" button (switch)**: When enabled this will show a `Translate to all locales` button on for all English text to translate the field into all available languages. + - **Field where this plugin is enabled (multi select)**: You can choose to which fields the plugin will be applied. > Options of `Field where this plugin is enabled`: