From fc8ae20e70782717dadfc591ae82fc0f30199dcd Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Mon, 3 Feb 2025 17:44:15 +0100 Subject: [PATCH] Localize reference block labels and properties in the block editing experience (#18201) * Localize reference block labels and properties in the block editing experience. * Revert description update. * Block entry: localize content-type name * Block entry: localize delete confirm modal --------- Co-authored-by: leekelleher --- .../src/assets/lang/en-us.ts | 3 ++- .../src/assets/lang/en.ts | 3 ++- .../block/context/block-entry.context.ts | 26 ++++++++++--------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts b/src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts index 296e936e12..7a6b62c538 100644 --- a/src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts +++ b/src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts @@ -2446,7 +2446,8 @@ export default { labelEditorSize: 'Overlay editor size', addCustomView: 'Add custom view', addSettingsElementType: 'Add settings', - confirmDeleteBlockMessage: 'Are you sure you want to delete the content %0%?', + confirmDeleteBlockTitle: 'Delete %0%?', + confirmDeleteBlockMessage: 'Are you sure you want to delete this %0%?', confirmDeleteBlockTypeMessage: 'Are you sure you want to delete the block configuration %0%?', confirmDeleteBlockTypeNotice: 'The content of this block will still be present, editing of this content\n will no longer be available and will be shown as unsupported content.\n ', diff --git a/src/Umbraco.Web.UI.Client/src/assets/lang/en.ts b/src/Umbraco.Web.UI.Client/src/assets/lang/en.ts index dcb602d07e..26b788feb6 100644 --- a/src/Umbraco.Web.UI.Client/src/assets/lang/en.ts +++ b/src/Umbraco.Web.UI.Client/src/assets/lang/en.ts @@ -2509,7 +2509,8 @@ export default { labelEditorSize: 'Overlay editor size', addCustomView: 'Add custom view', addSettingsElementType: 'Add settings', - confirmDeleteBlockMessage: 'Are you sure you want to delete the content %0%?', + confirmDeleteBlockTitle: 'Delete %0%?', + confirmDeleteBlockMessage: 'Are you sure you want to delete this %0%?', confirmDeleteBlockTypeMessage: 'Are you sure you want to delete the block configuration %0%?', confirmDeleteBlockTypeNotice: 'The content of this block will still be present, editing of this content\n will no longer be available and will be shown as unsupported content.\n ', diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts index c17d511676..27ad34859a 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts @@ -7,9 +7,7 @@ import type { UmbBlockDataValueModel, } from '../types.js'; import type { UmbBlockEntriesContext } from './block-entries.context.js'; -import type { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'; -import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UmbBooleanState, UmbClassState, @@ -21,16 +19,19 @@ import { } from '@umbraco-cms/backoffice/observable-api'; import { encodeFilePath, UmbReadOnlyVariantStateManager } from '@umbraco-cms/backoffice/utils'; import { umbConfirmModal } from '@umbraco-cms/backoffice/modal'; +import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api'; +import { UmbRoutePathAddendumContext } from '@umbraco-cms/backoffice/router'; +import { UmbVariantId } from '@umbraco-cms/backoffice/variant'; +import { UmbUfmVirtualRenderController } from '@umbraco-cms/backoffice/ufm'; +import type { Observable } from '@umbraco-cms/backoffice/external/rxjs'; +import type { UmbBlockTypeBaseModel } from '@umbraco-cms/backoffice/block-type'; +import type { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; import type { UmbContentTypeModel, UmbContentTypeStructureManager, UmbPropertyTypeModel, } from '@umbraco-cms/backoffice/content-type'; -import type { Observable } from '@umbraco-cms/backoffice/external/rxjs'; -import type { UmbBlockTypeBaseModel } from '@umbraco-cms/backoffice/block-type'; -import { UmbVariantId } from '@umbraco-cms/backoffice/variant'; -import { UmbUfmVirtualRenderController } from '@umbraco-cms/backoffice/ufm'; -import { UmbRoutePathAddendumContext } from '@umbraco-cms/backoffice/router'; +import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; export abstract class UmbBlockEntryContext< BlockManagerContextTokenType extends UmbContextToken, @@ -53,6 +54,8 @@ export abstract class UmbBlockEntryContext< #contentKey?: string; + readonly #localize = new UmbLocalizationController(this); + #pathAddendum = new UmbRoutePathAddendumContext(this); #variantId = new UmbClassState(undefined); protected readonly _variantId = this.#variantId.asObservable(); @@ -660,7 +663,7 @@ export abstract class UmbBlockEntryContext< this.observe( this.contentElementTypeName, (contentTypeName) => { - this.#label.setValue(contentTypeName ?? 'no name'); + this.#label.setValue(this.#localize.string(contentTypeName) || 'no name'); }, 'observeContentTypeName', ); @@ -699,11 +702,10 @@ export abstract class UmbBlockEntryContext< async requestDelete() { const blockName = this.getName(); - // TODO: Localizations missing [NL] await umbConfirmModal(this, { - headline: `Delete ${blockName}`, - content: `Are you sure you want to delete this ${blockName}?`, - confirmLabel: 'Delete', + headline: this.#localize.term('blockEditor_confirmDeleteBlockTitle', blockName), + content: this.#localize.term('blockEditor_confirmDeleteBlockMessage', blockName), + confirmLabel: this.#localize.term('general_delete'), color: 'danger', }); this.delete();