From 634c2149ef2975ab8828f673d718e8c56832f3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rge=20N=C3=A6ss?= Date: Tue, 10 Oct 2023 17:07:03 +0200 Subject: [PATCH] fixup! feat(i18n): convert file, image and imagetool input strings to use i18n primitives --- .../plugins/locale-no-nb/bundles/studio.ts | 21 ++++++++++++------- .../inputs/files/ImageInput/ImageInput.tsx | 2 +- .../inputs/files/common/PlaceholderText.tsx | 4 ++-- .../inputs/files/common/UploadProgress.tsx | 4 +--- .../sanity/src/core/i18n/bundles/studio.ts | 17 ++++++++++----- .../sanity/test/form/renderImageInput.tsx | 1 + 6 files changed, 31 insertions(+), 18 deletions(-) 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 52c546bd6b7..4a1c0f79fed 100644 --- a/dev/test-studio/plugins/locale-no-nb/bundles/studio.ts +++ b/dev/test-studio/plugins/locale-no-nb/bundles/studio.ts @@ -266,7 +266,7 @@ const studioResources: Record = { /** --- File (Image, File and ImageTool) Inputs --- */ /** Open image edit dialog */ - 'inputs.files.image.actions-menu.edit-details.label': 'Åpne bilde redigeringsdialog', + 'inputs.files.image.actions-menu.edit-details.label': 'Åpne bilderedigeringsdialog', /** Open image options menu */ 'inputs.files.image.actions-menu.options.label': 'Åpne bildeinnstillingsmeny', @@ -325,14 +325,21 @@ const studioResources: Record = { /** 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}}', + /** Drop to upload file */ + 'inputs.files.common.placeholder.drop-to-upload_file': 'Slipp for å laste opp fil', - /** Cannot upload `{{count}}` files */ - 'inputs.files.common.placeholder.cannot-upload-some-files': 'Kan ikke laste opp {{count}} filer', + /** Drop to upload image */ + 'inputs.files.common.placeholder.drop-to-upload_image': 'Slipp for å laste opp bilde', - /** Drag or paste `{{type}}` here */ - 'inputs.files.common.placeholder.drag-or-paste-to-upload': 'Dra eller lim inn {{type}} her', + /** Cannot upload `{{count}}` files */ + 'inputs.files.common.placeholder.cannot-upload-some-files_one': 'Kan ikke laste opp fil', + 'inputs.files.common.placeholder.cannot-upload-some-files_other': + 'Kan ikke laste opp {{count}} filer', + + /** Drag or paste file here */ + 'inputs.files.common.placeholder.drag-or-paste-to-upload_file': 'Dra eller lim inn fil her', + /** Drag or paste image here */ + 'inputs.files.common.placeholder.drag-or-paste-to-upload_image': 'Dra eller lim inn bilde her', /** Drop to upload */ 'inputs.files.common.drop-message.drop-to-upload': 'Slipp for å laste opp', diff --git a/packages/sanity/src/core/form/inputs/files/ImageInput/ImageInput.tsx b/packages/sanity/src/core/form/inputs/files/ImageInput/ImageInput.tsx index 56ca78b2480..5c02b0f2c13 100644 --- a/packages/sanity/src/core/form/inputs/files/ImageInput/ImageInput.tsx +++ b/packages/sanity/src/core/form/inputs/files/ImageInput/ImageInput.tsx @@ -75,7 +75,7 @@ export interface BaseImageInputProps observeAsset: (documentId: string) => Observable resolveUploader: UploaderResolver client: SanityClient - t: TFunction + t: (key: string, values?: Record) => string } const getDevicePixelRatio = () => { diff --git a/packages/sanity/src/core/form/inputs/files/common/PlaceholderText.tsx b/packages/sanity/src/core/form/inputs/files/common/PlaceholderText.tsx index ee91af7caf7..2468e9f85be 100644 --- a/packages/sanity/src/core/form/inputs/files/common/PlaceholderText.tsx +++ b/packages/sanity/src/core/form/inputs/files/common/PlaceholderText.tsx @@ -47,7 +47,7 @@ export function PlaceholderText(props: Props) { if (hoveringFiles && directUploads && !readOnly) { if (acceptedFiles.length > 0) { - return t('inputs.files.common.placeholder.drop-to-upload', {type}) + return t('inputs.files.common.placeholder.drop-to-upload', {context: type}) } if (rejectedFilesCount > 0) { return t('inputs.files.common.placeholder.cannot-upload-some-files', { @@ -56,7 +56,7 @@ export function PlaceholderText(props: Props) { } } - return t('inputs.files.common.placeholder.drag-or-paste-to-upload') + return t('inputs.files.common.placeholder.drag-or-paste-to-upload', {context: type}) }, [acceptedFiles.length, directUploads, hoveringFiles, readOnly, rejectedFilesCount, t, type]) return ( diff --git a/packages/sanity/src/core/form/inputs/files/common/UploadProgress.tsx b/packages/sanity/src/core/form/inputs/files/common/UploadProgress.tsx index 81a72e552b4..132b1eb5e8e 100644 --- a/packages/sanity/src/core/form/inputs/files/common/UploadProgress.tsx +++ b/packages/sanity/src/core/form/inputs/files/common/UploadProgress.tsx @@ -35,9 +35,7 @@ export function UploadProgress({uploadState, onCancel, onStale, height}: Props) t={t} i18nKey="input.files.common.upload-progress" components={{ - FileName: () => ( - {filename ? filename : '...'} - ), + FileName: () => {filename ? filename : '…'}, }} /> diff --git a/packages/sanity/src/core/i18n/bundles/studio.ts b/packages/sanity/src/core/i18n/bundles/studio.ts index 0efa95f36eb..0d54b27cc41 100644 --- a/packages/sanity/src/core/i18n/bundles/studio.ts +++ b/packages/sanity/src/core/i18n/bundles/studio.ts @@ -269,14 +269,21 @@ export const studioLocaleStrings = { /** Read only */ 'inputs.files.common.placeholder.read-only': 'Read only', - /** Drop to upload `{{type}}` */ - 'inputs.files.common.placeholder.drop-to-upload': 'Drop to upload {{type}}', + /** Drop to upload image */ + 'inputs.files.common.placeholder.drop-to-upload_image': 'Drop to upload image', + + /** Drop to upload file */ + 'inputs.files.common.placeholder.drop-to-upload_file': 'Drop to upload file', /** Cannot upload `{{count}}` files */ - 'inputs.files.common.placeholder.cannot-upload-some-files': 'Cannot upload {{count}} files', + 'inputs.files.common.placeholder.cannot-upload-some-files_one': 'Cannot upload file', + 'inputs.files.common.placeholder.cannot-upload-some-files_other': 'Cannot upload {{count}} files', + + /** Drag or paste type here */ + 'inputs.files.common.placeholder.drag-or-paste-to-upload_file': 'Drag or paste file here', - /** Drag or paste `{{type}}` here */ - 'inputs.files.common.placeholder.drag-or-paste-to-upload': 'Drag or paste {{type}} here', + /** Drag or paste image here */ + 'inputs.files.common.placeholder.drag-or-paste-to-upload_image': 'Drag or paste image here', /** Drop to upload */ 'inputs.files.common.drop-message.drop-to-upload': 'Drop to upload', diff --git a/packages/sanity/test/form/renderImageInput.tsx b/packages/sanity/test/form/renderImageInput.tsx index a61c302cad0..61288837bb5 100644 --- a/packages/sanity/test/form/renderImageInput.tsx +++ b/packages/sanity/test/form/renderImageInput.tsx @@ -35,6 +35,7 @@ export async function renderImageInput(options: { ...restProps, assetSources, client, + t: (key: string, values?: Record) => key, imageUrlBuilder, observeAsset, resolveUploader,