diff --git a/src/actions/DuplicateWithTranslationsAction.tsx b/src/actions/DuplicateWithTranslationsAction.tsx index eed3293..4bea8f8 100644 --- a/src/actions/DuplicateWithTranslationsAction.tsx +++ b/src/actions/DuplicateWithTranslationsAction.tsx @@ -1,4 +1,4 @@ -import {CopyIcon} from '@sanity/icons' +import {CopyIcon, TranslateIcon} from '@sanity/icons' import {useToast} from '@sanity/ui' import {uuid} from '@sanity/uuid' import {useCallback, useMemo, useState} from 'react' @@ -21,10 +21,10 @@ import {useRouter} from 'sanity/router' import {structureLocaleNamespace} from 'sanity/structure' import {METADATA_SCHEMA_NAME, TRANSLATIONS_ARRAY_NAME} from '../constants' +import {documenti18nLocaleNamespace} from '../i18n' const DISABLED_REASON_KEY = { - // TODO: add localization - I18N_METADATA_NOT_FOUND: 'This document does not have i18n metadata', + METADATA_NOT_FOUND: 'action.duplicate.disabled.missing-metadata', NOTHING_TO_DUPLICATE: 'action.duplicate.disabled.nothing-to-duplicate', NOT_READY: 'action.duplicate.disabled.not-ready', } @@ -46,7 +46,8 @@ export const DuplicateWithTranslationsAction: DocumentActionComponent = ({ const metadataDocument = useI18nMetadata(id) const client = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS) const toast = useToast() - const {t} = useTranslation(structureLocaleNamespace) + const {t: structureT} = useTranslation(structureLocaleNamespace) + const {t: documenti18nT} = useTranslation(documenti18nLocaleNamespace) const currentUser = useCurrentUser() const handle = useCallback(async () => { @@ -174,7 +175,7 @@ export const DuplicateWithTranslationsAction: DocumentActionComponent = ({ return { icon: CopyIcon, disabled: true, - label: t('action.duplicate.label'), + label: documenti18nT('action.duplicate.label'), title: ( import('./resources'), + }) diff --git a/src/i18n/resources.ts b/src/i18n/resources.ts new file mode 100644 index 0000000..363e709 --- /dev/null +++ b/src/i18n/resources.ts @@ -0,0 +1,5 @@ +export default { + 'action.duplicate.label': 'Duplicate with translations', + 'action.duplicate.disabled.missing-metadata': + 'The document cannot be duplicated because the metadata document is missing', +} diff --git a/src/plugin.tsx b/src/plugin.tsx index 2d2b4e7..20a3ad0 100644 --- a/src/plugin.tsx +++ b/src/plugin.tsx @@ -9,6 +9,7 @@ import {DocumentInternationalizationProvider} from './components/DocumentInterna import {DocumentInternationalizationMenu} from './components/DocumentInternationalizationMenu' import OptimisticallyStrengthen from './components/OptimisticallyStrengthen' import {API_VERSION, DEFAULT_CONFIG, METADATA_SCHEMA_NAME} from './constants' +import {documentInternationalizationUsEnglishLocaleBundle} from './i18n' import metadata from './schema/translation/metadata' import type {PluginConfig, TranslationReference} from './types' @@ -39,6 +40,10 @@ export const documentInternationalization = definePlugin( }, }, + i18n: { + bundles: [documentInternationalizationUsEnglishLocaleBundle], + }, + // Adds: // - A bulk-publishing UI component to the form // - Will only work for projects on a compatible plan