From e96b449894967d1ecbad7f752c09bc9b0dc2c9b3 Mon Sep 17 00:00:00 2001 From: Tommy Petty Date: Thu, 19 Oct 2023 14:01:04 -0400 Subject: [PATCH 1/4] feat(i18n): add localization for UnknownPaneType --- packages/sanity/src/desk/i18n/resources.ts | 10 ++++++++++ .../sanity/src/desk/panes/unknown/UnknownPaneType.tsx | 8 +++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/sanity/src/desk/i18n/resources.ts b/packages/sanity/src/desk/i18n/resources.ts index 30422db81eb..307cfc5b2bb 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 682024fe838..4173713d443 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, useTranslation} from 'sanity' interface UnknownPaneProps { isSelected: boolean @@ -15,6 +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 +25,11 @@ export function UnknownPane(props: UnknownPaneProps) { {typeof type === 'string' ? ( - Structure item of type {type} is not a known entity. + {t('panes.unknown-pane-type.unknown-type.text', {type: type})} ) : ( - Structure item is missing required type property. + {t('panes.unknown-pane-type.missing-type.text')} )} From 331f266e061b5f1e7f8d7e4e0358ebe32c8aa9d8 Mon Sep 17 00:00:00 2001 From: Tommy Petty Date: Thu, 19 Oct 2023 14:42:08 -0400 Subject: [PATCH 2/4] feat(i18n): disable no-literal-string lint rule for __workshop__ --- .../sanity/src/desk/components/pane/__workshop__/.eslintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sanity/src/desk/components/pane/__workshop__/.eslintrc b/packages/sanity/src/desk/components/pane/__workshop__/.eslintrc index b18e2f034a9..52a029a6017 100644 --- a/packages/sanity/src/desk/components/pane/__workshop__/.eslintrc +++ b/packages/sanity/src/desk/components/pane/__workshop__/.eslintrc @@ -1,5 +1,6 @@ { "rules": { - "no-nested-ternary": "off" + "no-nested-ternary": "off", + "i18next/no-literal-string": "off" } } From da63f89d34600b63a2b59ec19ef5d63c2950cfe4 Mon Sep 17 00:00:00 2001 From: Tommy Petty Date: Thu, 19 Oct 2023 14:51:34 -0400 Subject: [PATCH 3/4] feat(i18n): disable no-literal-string lint rule for timeline/__workshop__ --- .../src/desk/panes/document/timeline/__workshop__/.eslintrc | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/sanity/src/desk/panes/document/timeline/__workshop__/.eslintrc diff --git a/packages/sanity/src/desk/panes/document/timeline/__workshop__/.eslintrc b/packages/sanity/src/desk/panes/document/timeline/__workshop__/.eslintrc new file mode 100644 index 00000000000..a38070b9319 --- /dev/null +++ b/packages/sanity/src/desk/panes/document/timeline/__workshop__/.eslintrc @@ -0,0 +1,5 @@ +{ + "rules": { + "i18next/no-literal-string": "off" + } +} \ No newline at end of file From a1370a9286455568d38fdd3962b923e4e726d463 Mon Sep 17 00:00:00 2001 From: Tommy Petty Date: Thu, 26 Oct 2023 09:43:11 -0400 Subject: [PATCH 4/4] feat(i18n): fix to properly style code elements with translation --- packages/sanity/src/desk/i18n/resources.ts | 4 ++-- .../src/desk/panes/unknown/UnknownPaneType.tsx | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/sanity/src/desk/i18n/resources.ts b/packages/sanity/src/desk/i18n/resources.ts index 307cfc5b2bb..a30801bd2aa 100644 --- a/packages/sanity/src/desk/i18n/resources.ts +++ b/packages/sanity/src/desk/i18n/resources.ts @@ -170,11 +170,11 @@ const deskLocaleStrings = { /** The text to display when type is missing */ 'panes.unknown-pane-type.missing-type.text': - 'Structure item is missing required type property.', + '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.', + '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 4173713d443..0e4f3580894 100644 --- a/packages/sanity/src/desk/panes/unknown/UnknownPaneType.tsx +++ b/packages/sanity/src/desk/panes/unknown/UnknownPaneType.tsx @@ -2,7 +2,7 @@ import {Box, Text} from '@sanity/ui' import React from 'react' import {Pane, PaneContent, PaneHeader} from '../../components/pane' import {deskLocaleNamespace} from '../../i18n' -import {isRecord, useTranslation} from 'sanity' +import {isRecord, Translate, useTranslation} from 'sanity' interface UnknownPaneProps { isSelected: boolean @@ -17,7 +17,6 @@ export function UnknownPane(props: UnknownPaneProps) { const {isSelected, pane, paneKey} = props const type = (isRecord(pane) && pane.type) || null const {t} = useTranslation(deskLocaleNamespace) - return ( @@ -25,11 +24,20 @@ export function UnknownPane(props: UnknownPaneProps) { {typeof type === 'string' ? ( - {t('panes.unknown-pane-type.unknown-type.text', {type: type})} + {children}}} + values={{type}} + /> ) : ( - {t('panes.unknown-pane-type.missing-type.text')} + {children}}} + /> )}