From 7d69b319263c4c3d559bafc22d5343050c44a62d Mon Sep 17 00:00:00 2001 From: Tommy Petty Date: Thu, 2 Nov 2023 08:52:47 -0400 Subject: [PATCH] feat(i18n): add localization for UnknownPaneType (#5019) * feat(i18n): add localization for UnknownPaneType * feat(i18n): disable no-literal-string lint rule for __workshop__ * feat(i18n): disable no-literal-string lint rule for timeline/__workshop__ * feat(i18n): fix to properly style code elements with translation --- packages/sanity/src/desk/i18n/resources.ts | 10 ++++++++++ .../src/desk/panes/unknown/UnknownPaneType.tsx | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/sanity/src/desk/i18n/resources.ts b/packages/sanity/src/desk/i18n/resources.ts index 30422db81eb5..a30801bd2aae 100644 --- a/packages/sanity/src/desk/i18n/resources.ts +++ b/packages/sanity/src/desk/i18n/resources.ts @@ -165,6 +165,16 @@ const deskLocaleStrings = { /** --- "PRODUCTION PREVIEW", eg link to content --- */ 'production-preview.menu-item.title': 'Open preview', + + /** -- UNKNOWN PANE TYPE */ + + /** The text to display when type is missing */ + 'panes.unknown-pane-type.missing-type.text': + 'Structure item is missing required type property.', + + /** The text to display when type is unknown */ + 'panes.unknown-pane-type.unknown-type.text': + 'Structure item of type {{type}} is not a known entity.', } /** diff --git a/packages/sanity/src/desk/panes/unknown/UnknownPaneType.tsx b/packages/sanity/src/desk/panes/unknown/UnknownPaneType.tsx index 682024fe8383..0e4f3580894c 100644 --- a/packages/sanity/src/desk/panes/unknown/UnknownPaneType.tsx +++ b/packages/sanity/src/desk/panes/unknown/UnknownPaneType.tsx @@ -1,7 +1,8 @@ import {Box, Text} from '@sanity/ui' import React from 'react' import {Pane, PaneContent, PaneHeader} from '../../components/pane' -import {isRecord} from 'sanity' +import {deskLocaleNamespace} from '../../i18n' +import {isRecord, Translate, useTranslation} from 'sanity' interface UnknownPaneProps { isSelected: boolean @@ -15,7 +16,7 @@ interface UnknownPaneProps { export function UnknownPane(props: UnknownPaneProps) { const {isSelected, pane, paneKey} = props const type = (isRecord(pane) && pane.type) || null - + const {t} = useTranslation(deskLocaleNamespace) return ( @@ -23,11 +24,20 @@ export function UnknownPane(props: UnknownPaneProps) { {typeof type === 'string' ? ( - Structure item of type {type} is not a known entity. + {children}}} + values={{type}} + /> ) : ( - Structure item is missing required type property. + {children}}} + /> )}