Skip to content

Commit

Permalink
feat(i18n): updates translation for desk panes
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpetty committed Nov 2, 2023
1 parent 50455d5 commit 7391658
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 13 deletions.
3 changes: 3 additions & 0 deletions packages/sanity/src/core/i18n/bundles/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export const studioLocaleStrings = {
/** Label for loading history */
'timeline.loading-history': 'Loading history',

/** The aria-label for the list of revisions in the timeline */
'timeline.list.aria-label': 'Document revisions',

/**
* Label for determining since which version the changes for timeline menu dropdown are showing.
* Receives the time label as a parameter.
Expand Down
29 changes: 28 additions & 1 deletion packages/sanity/src/desk/i18n/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,18 @@ const deskLocaleStrings = {
'production-preview.menu-item.title': 'Open preview',

/** -- DESK PANES -- */
/** The tool tipe for the split pane button on the document panel header */
/** The tool tip for the split pane button on the document panel header */
'buttons.split-pane-button.tooltip': 'Split pane right',

/** The aria-label for the split pane button on the document panel header */
'buttons.split-pane-button.aria-label': 'Split pane right',

/** The title for the close button on the split pane on the document panel header */
'buttons.split-pane-close-button.title': 'Close split pane',

/** The title for the close group button on the split pane on the document panel header */
'buttons.split-pane-close-group-button.title': 'Close pane group',

/** The text content for the deleted document banner */
'banners.deleted-document-banner.text': 'This document has been deleted.',

Expand Down Expand Up @@ -254,6 +263,9 @@ const deskLocaleStrings = {
/** The error text on the document list pane */
'panes.document-list-pane.error.text': 'Error: <Code>{{error}}</Code>',

/** The text for the retry button on the document list pane */
'panes.document-list-pane.error.retry-button.text': 'Retry',

/** The summary title when displaying an error for a document operation result */
'panes.document-operation-results.error.summary.title': 'Details',

Expand Down Expand Up @@ -296,6 +308,18 @@ const deskLocaleStrings = {
/** The text used in the document header title if no other title can be determined */
'panes.document-header-title.untitled.text': 'Untitled',

/** The aria-label for the search input on the document list pane */
'panes.document-list-pane.search-input.aria-label': 'Search list',

/** The search input for the search input on the document list pane */
'panes.document-list-pane.search-input.placeholder': 'Search list',

/** The action menu button aria-label */
'buttons.action-menu-button.aria-label': 'Open document actions',

/** the placeholder text for the search input on the inspect dialog */
'inputs.inspect-dialog.search.placeholder': 'Search',

/** -- UNKNOWN PANE TYPE */

/** The text to display when type is missing */
Expand All @@ -305,6 +329,9 @@ const deskLocaleStrings = {
/** The text to display when type is unknown */
'panes.unknown-pane-type.unknown-type.text':
'Structure item of type <Code>{{type}}</Code> is not a known entity.',

/** The title of the unknown pane */
'panes.unknown-pane-type.title': 'Unknown pane type',
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const DocumentPanelHeader = memo(
portal
>
<Button
aria-label="Split pane right"
aria-label={t('buttons.split-pane-button.aria-label')}
icon={SplitVerticalIcon}
key="split-pane-button"
mode="bleed"
Expand All @@ -138,7 +138,7 @@ export const DocumentPanelHeader = memo(
key="close-view-button"
mode="bleed"
onClick={onPaneClose}
title="Close split pane"
title={t('buttons.split-pane-close-button.title')}
/>
)}

Expand All @@ -147,7 +147,7 @@ export const DocumentPanelHeader = memo(
icon={CloseIcon}
key="close-view-button"
mode="bleed"
title="Close pane group"
title={t('buttons.split-pane-close-group-button.title')}
as={BackLink}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {SearchIcon} from '@sanity/icons'
import {TextInput} from '@sanity/ui'
import React, {useCallback} from 'react'
import {deskLocaleNamespace} from '../../../i18n'
import {useTranslation} from 'sanity'

export function Search(props: {onChange: (q: string) => void; query: string}) {
const {onChange, query} = props
Expand All @@ -9,12 +11,13 @@ export function Search(props: {onChange: (q: string) => void; query: string}) {
(event: React.ChangeEvent<HTMLInputElement>) => onChange(event.target.value),
[onChange],
)
const {t} = useTranslation(deskLocaleNamespace)

return (
<TextInput
icon={SearchIcon}
onChange={handleChange}
placeholder="Search"
placeholder={t('inputs.inspect-dialog.search.placeholder')}
radius={2}
value={query || ''}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import React, {
} from 'react'
import {isValidElementType} from 'react-is'
import {ActionStateDialog} from './ActionStateDialog'
import {DocumentActionDescription, LegacyLayerProvider} from 'sanity'
import {deskLocaleNamespace} from '../../../i18n'
import {DocumentActionDescription, LegacyLayerProvider, useTranslation} from 'sanity'

export interface ActionMenuButtonProps {
actionStates: DocumentActionDescription[]
Expand Down Expand Up @@ -50,6 +51,7 @@ export function ActionMenuButton(props: ActionMenuButtonProps) {
)

const currentAction = actionStates[actionIndex]
const {t} = useTranslation(deskLocaleNamespace)

return (
<>
Expand All @@ -58,7 +60,7 @@ export function ActionMenuButton(props: ActionMenuButtonProps) {
button={
<Button
data-testid="action-menu-button"
aria-label="Open document actions"
aria-label={t('buttons.action-menu-button.aria-label')}
disabled={disabled}
icon={ChevronDownIcon}
mode="ghost"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const Timeline = ({
<ListWrapper direction="column">
<CommandList
activeItemDataAttr="data-hovered"
ariaLabel="Document revisions"
ariaLabel={t('timeline.list.aria-label')}
autoFocus="list"
initialIndex={selectedIndex}
initialScrollAlign="center"
Expand Down
16 changes: 13 additions & 3 deletions packages/sanity/src/desk/panes/documentList/DocumentListPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ import {DocumentListPaneContent} from './DocumentListPaneContent'
import {DocumentListPaneHeader} from './DocumentListPaneHeader'
import {LoadingVariant, SortOrder} from './types'
import {useDocumentList} from './useDocumentList'
import {GeneralPreviewLayoutKey, SourceProvider, useSchema, useSource, useUnique} from 'sanity'
import {deskLocaleNamespace} from '../../i18n'
import {
GeneralPreviewLayoutKey,
SourceProvider,
useSchema,
useSource,
useTranslation,
useUnique,
} from 'sanity'

type DocumentListPaneProps = BaseDeskToolPaneProps<'documentList'>

Expand Down Expand Up @@ -213,11 +221,13 @@ export const DocumentListPane = memo(function DocumentListPane(props: DocumentLi
return 'initial'
}, [isLoading, items.length])

const {t} = useTranslation(deskLocaleNamespace)

const searchInput = (
<Box paddingX={2} paddingBottom={2}>
<SearchCard radius={4} tone="transparent">
<TextInput
aria-label="Search list"
aria-label={t('panes.document-list-pane.search-input.aria-label')}
autoComplete="off"
border={false}
clearButton={Boolean(searchQuery)}
Expand All @@ -227,7 +237,7 @@ export const DocumentListPane = memo(function DocumentListPane(props: DocumentLi
onChange={handleQueryChange}
onClear={handleClearSearch}
onKeyDown={handleSearchKeyDown}
placeholder="Search list"
placeholder={t('panes.document-list-pane.search-input.placeholder')}
radius={2}
ref={setSearchInputElement}
spellCheck={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ export function DocumentListPaneContent(props: DocumentListPaneContentProps) {

{onRetry && (
<Box>
<Button icon={SyncIcon} onClick={onRetry} text="Retry" tone="primary" />
<Button
icon={SyncIcon}
onClick={onRetry}
text={t('panes.document-list-pane.error.retry-button.text')}
tone="primary"
/>
</Box>
)}
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/src/desk/panes/unknown/UnknownPaneType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function UnknownPane(props: UnknownPaneProps) {
const {t} = useTranslation(deskLocaleNamespace)
return (
<Pane id={paneKey} selected={isSelected}>
<PaneHeader title="Unknown pane type" />
<PaneHeader title={t('panes.unknown-pane-type.title')} />
<PaneContent>
<Box padding={4}>
{typeof type === 'string' ? (
Expand Down

0 comments on commit 7391658

Please sign in to comment.