Skip to content

Commit fc8ae20

Browse files
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 <[email protected]>
1 parent 1f4b3e2 commit fc8ae20

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2446,7 +2446,8 @@ export default {
24462446
labelEditorSize: 'Overlay editor size',
24472447
addCustomView: 'Add custom view',
24482448
addSettingsElementType: 'Add settings',
2449-
confirmDeleteBlockMessage: 'Are you sure you want to delete the content <strong>%0%</strong>?',
2449+
confirmDeleteBlockTitle: 'Delete %0%?',
2450+
confirmDeleteBlockMessage: 'Are you sure you want to delete this %0%?',
24502451
confirmDeleteBlockTypeMessage: 'Are you sure you want to delete the block configuration <strong>%0%</strong>?',
24512452
confirmDeleteBlockTypeNotice:
24522453
'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 ',

src/Umbraco.Web.UI.Client/src/assets/lang/en.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2509,7 +2509,8 @@ export default {
25092509
labelEditorSize: 'Overlay editor size',
25102510
addCustomView: 'Add custom view',
25112511
addSettingsElementType: 'Add settings',
2512-
confirmDeleteBlockMessage: 'Are you sure you want to delete the content <strong>%0%</strong>?',
2512+
confirmDeleteBlockTitle: 'Delete %0%?',
2513+
confirmDeleteBlockMessage: 'Are you sure you want to delete this %0%?',
25132514
confirmDeleteBlockTypeMessage: 'Are you sure you want to delete the block configuration <strong>%0%</strong>?',
25142515
confirmDeleteBlockTypeNotice:
25152516
'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 ',

src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import type {
77
UmbBlockDataValueModel,
88
} from '../types.js';
99
import type { UmbBlockEntriesContext } from './block-entries.context.js';
10-
import type { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
1110
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
12-
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
1311
import {
1412
UmbBooleanState,
1513
UmbClassState,
@@ -21,16 +19,19 @@ import {
2119
} from '@umbraco-cms/backoffice/observable-api';
2220
import { encodeFilePath, UmbReadOnlyVariantStateManager } from '@umbraco-cms/backoffice/utils';
2321
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
22+
import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api';
23+
import { UmbRoutePathAddendumContext } from '@umbraco-cms/backoffice/router';
24+
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
25+
import { UmbUfmVirtualRenderController } from '@umbraco-cms/backoffice/ufm';
26+
import type { Observable } from '@umbraco-cms/backoffice/external/rxjs';
27+
import type { UmbBlockTypeBaseModel } from '@umbraco-cms/backoffice/block-type';
28+
import type { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
2429
import type {
2530
UmbContentTypeModel,
2631
UmbContentTypeStructureManager,
2732
UmbPropertyTypeModel,
2833
} from '@umbraco-cms/backoffice/content-type';
29-
import type { Observable } from '@umbraco-cms/backoffice/external/rxjs';
30-
import type { UmbBlockTypeBaseModel } from '@umbraco-cms/backoffice/block-type';
31-
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
32-
import { UmbUfmVirtualRenderController } from '@umbraco-cms/backoffice/ufm';
33-
import { UmbRoutePathAddendumContext } from '@umbraco-cms/backoffice/router';
34+
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
3435

3536
export abstract class UmbBlockEntryContext<
3637
BlockManagerContextTokenType extends UmbContextToken<BlockManagerContextType>,
@@ -53,6 +54,8 @@ export abstract class UmbBlockEntryContext<
5354

5455
#contentKey?: string;
5556

57+
readonly #localize = new UmbLocalizationController(this);
58+
5659
#pathAddendum = new UmbRoutePathAddendumContext(this);
5760
#variantId = new UmbClassState<UmbVariantId | undefined>(undefined);
5861
protected readonly _variantId = this.#variantId.asObservable();
@@ -660,7 +663,7 @@ export abstract class UmbBlockEntryContext<
660663
this.observe(
661664
this.contentElementTypeName,
662665
(contentTypeName) => {
663-
this.#label.setValue(contentTypeName ?? 'no name');
666+
this.#label.setValue(this.#localize.string(contentTypeName) || 'no name');
664667
},
665668
'observeContentTypeName',
666669
);
@@ -699,11 +702,10 @@ export abstract class UmbBlockEntryContext<
699702

700703
async requestDelete() {
701704
const blockName = this.getName();
702-
// TODO: Localizations missing [NL]
703705
await umbConfirmModal(this, {
704-
headline: `Delete ${blockName}`,
705-
content: `Are you sure you want to delete this ${blockName}?`,
706-
confirmLabel: 'Delete',
706+
headline: this.#localize.term('blockEditor_confirmDeleteBlockTitle', blockName),
707+
content: this.#localize.term('blockEditor_confirmDeleteBlockMessage', blockName),
708+
confirmLabel: this.#localize.term('general_delete'),
707709
color: 'danger',
708710
});
709711
this.delete();

0 commit comments

Comments
 (0)