From 7a26b95ec73217e3994ec00220144b77fbe9d6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rge=20N=C3=A6ss?= Date: Mon, 9 Oct 2023 16:26:30 +0200 Subject: [PATCH] feat(i18n): convert file, image and imagetool input strings to use i18n primitives --- .../plugins/locale-no-nb/bundles/studio.ts | 102 ++++++++++++++++++ .../files/ImageInput/ImageActionsMenu.tsx | 6 +- .../inputs/files/ImageInput/ImageInput.tsx | 16 +-- .../inputs/files/ImageInput/ImagePreview.tsx | 23 ++-- .../files/ImageInput/InvalidImageWarning.tsx | 9 +- .../files/ImageToolInput/ImageToolInput.tsx | 6 +- .../form/inputs/files/common/ActionsMenu.tsx | 33 ++++-- .../form/inputs/files/common/DropMessage.tsx | 16 +-- .../inputs/files/common/PlaceholderText.tsx | 21 ++-- .../inputs/files/common/UploadPlaceholder.tsx | 1 + .../inputs/files/common/UploadProgress.tsx | 21 ++-- .../inputs/files/common/UploadWarning.tsx | 18 +++- .../src/core/form/inputs/files/constants.ts | 6 ++ .../form/studio/inputs/StudioImageInput.tsx | 3 + .../sanity/src/core/i18n/bundles/studio.ts | 43 ++++++++ 15 files changed, 263 insertions(+), 61 deletions(-) create mode 100644 packages/sanity/src/core/form/inputs/files/constants.ts diff --git a/dev/test-studio/plugins/locale-no-nb/bundles/studio.ts b/dev/test-studio/plugins/locale-no-nb/bundles/studio.ts index c83c1e412eb2..cfba5d9b258d 100644 --- a/dev/test-studio/plugins/locale-no-nb/bundles/studio.ts +++ b/dev/test-studio/plugins/locale-no-nb/bundles/studio.ts @@ -101,6 +101,108 @@ const studioResources: Record = { /** Label for selecting a hour preset. Receives a `time` param as a string on hh:mm format and a `date` param as a Date instance denoting the preset date */ 'inputs.datetime.calendar.action.set-to-time-preset': '{{time}} on {{date, datetime}}', + + /** --- File (Image, File and ImageTool) Inputs --- */ + + /** Open image edit dialog */ + 'inputs.files.image.actions-menu.edit-details.label': 'Åpne bilde redigeringsdialog', + + /** Open image options menu */ + 'inputs.files.image.actions-menu.options.label': 'Åpne bildeinnstillingsmeny', + + /** The upload could not be completed at this time. */ + 'inputs.files.image.upload-error.description': + 'Opplastingen kunne ikke fullføres på dette tidspunktet.', + + /** Upload failed */ + 'inputs.files.image.upload-error.title': 'Opplasting mislyktes', + + /** Edit hotspot and crop */ + 'inputs.files.image.hotspot-dialog.title': 'Rediger fokuspunkt og beskjær', + + /** Preview of uploaded image */ + 'inputs.files.image.preview-uploaded-image': 'Forhåndsvisning av opplastet bilde', + + /** Cannot upload this file here */ + 'inputs.files.image.drag-overlay.cannot-upload-here': 'Kan ikke laste opp denne filen her', + + /** This field is read only */ + 'inputs.files.image.drag-overlay.this-field-is-read-only': 'Dette feltet er skrivebeskyttet', + + /** Drop image to upload */ + 'inputs.files.image.drag-overlay.drop-to-upload-image': 'Slipp bilde for å laste opp', + + /** Invalid image value */ + 'inputs.files.image.invalid-image-warning.title': 'Ugyldig bildeverdi', + + /** The value of this field is not a valid image. Resetting this field will let you choose a new image. */ + 'inputs.files.image.invalid-image-warning.description': + 'Verdien i dette feltet er ikke et gyldig bilde. Ved å tilbakestille dette feltet kan du velge et nytt bilde.', + + /** The URL is copied to the clipboard */ + 'inputs.files.common.actions-menu.notification.url-copied': + 'URL-en er kopiert til utklippstavlen', + + /** Replace */ + 'inputs.files.common.actions-menu.replace.label': 'Erstatt', + + /** Upload */ + 'inputs.files.common.actions-menu.upload.label': 'Last opp', + + /** Download */ + 'inputs.files.common.actions-menu.download.label': 'Last ned', + + /** Copy URL */ + 'inputs.files.common.actions-menu.copy-url.label': 'Kopier URL', + + /** Clear field */ + 'inputs.files.common.actions-menu.clear-field.label': 'Tøm felt', + + /** Can't upload files here */ + 'inputs.files.common.placeholder.upload-not-supported': 'Kan ikke laste opp filer her', + + /** Read only */ + 'inputs.files.common.placeholder.read-only': 'Skrivebeskyttet', + + /** Drop to upload `{{type}}` */ + 'inputs.files.common.placeholder.drop-to-upload': 'Slipp for å laste opp {{type}}', + + /** Cannot upload `{{count}}` files */ + 'inputs.files.common.placeholder.cannot-upload-some-files': 'Kan ikke laste opp {{count}} filer', + + /** Drag or paste `{{type}}` here */ + 'inputs.files.common.placeholder.drag-or-paste-to-upload': 'Dra eller lim inn {{type}} her', + + /** Drop to upload */ + 'inputs.files.common.drop-message.drop-to-upload': 'Slipp for å laste opp', + + /** Drop to upload `{{count}}` file */ + 'inputs.files.common.drop-message.drop-to-upload-multi_one': + 'Slipp for å laste opp {{count}} fil', + + /** Drop to upload `{{count}}` files */ + 'inputs.files.common.drop-message.drop-to-upload-multi_other': + 'Slipp for å laste opp {{count}} filer', + + /** Uploading */ + 'input.files.common.upload-progress': 'Laster opp ', + + /** Incomplete upload */ + 'inputs.files.common.stale-upload-warning.title': 'Ufullstendig opplasting', + + /** An upload has made no progress for at least `{{staleThresholdMinutes}}` minutes and likely got interrupted. You can safely clear the incomplete upload and try uploading again. */ + 'inputs.files.common.stale-upload-warning.description': + 'En opplasting har ikke gjort fremskritt på minst {{staleThresholdMinutes}} minutter og ble sannsynligvis avbrutt. Du kan trygt fjerne den ufullstendige opplastingen og prøve å laste opp på nytt.', + + /** Clear upload */ + 'inputs.files.common.stale-upload-warning.clear': 'Fjern opplasting', + + /** Hotspot & Crop */ + 'inputs.files.imagetool.field.title': 'Fokuspunkt & beskjæring', + + /** Adjust the rectangle to crop image. Adjust the circle to specify the area that should always be visible. */ + 'inputs.files.imagetool.field.description': + 'Juster rektangelet for å beskjære bildet. Juster sirkelen for å spesifisere området som alltid skal være synlig.', } export default studioResources diff --git a/packages/sanity/src/core/form/inputs/files/ImageInput/ImageActionsMenu.tsx b/packages/sanity/src/core/form/inputs/files/ImageInput/ImageActionsMenu.tsx index 93a02fad7909..032cf5211ffd 100644 --- a/packages/sanity/src/core/form/inputs/files/ImageInput/ImageActionsMenu.tsx +++ b/packages/sanity/src/core/form/inputs/files/ImageInput/ImageActionsMenu.tsx @@ -2,6 +2,7 @@ import React, {MouseEventHandler, ReactNode, useCallback, useEffect, useState} f import {EllipsisVerticalIcon, CropIcon} from '@sanity/icons' import {Button, Inline, Menu, Popover, useClickOutside, useGlobalKeyDown} from '@sanity/ui' import styled from 'styled-components' +import {useTranslation} from '../../../../i18n' export const MenuActionsWrapper = styled(Inline)` position: absolute; @@ -79,11 +80,12 @@ export function ImageActionsMenu(props: ImageActionsMenuProps) { } }, [isMenuOpen, menuElement]) + const {t} = useTranslation() return ( {showEdit && (