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 <leekelleher@gmail.com>
This commit is contained in:
@@ -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 <strong>%0%</strong>?',
|
||||
confirmDeleteBlockTitle: 'Delete %0%?',
|
||||
confirmDeleteBlockMessage: 'Are you sure you want to delete this %0%?',
|
||||
confirmDeleteBlockTypeMessage: 'Are you sure you want to delete the block configuration <strong>%0%</strong>?',
|
||||
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 ',
|
||||
|
||||
@@ -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 <strong>%0%</strong>?',
|
||||
confirmDeleteBlockTitle: 'Delete %0%?',
|
||||
confirmDeleteBlockMessage: 'Are you sure you want to delete this %0%?',
|
||||
confirmDeleteBlockTypeMessage: 'Are you sure you want to delete the block configuration <strong>%0%</strong>?',
|
||||
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 ',
|
||||
|
||||
@@ -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<BlockManagerContextType>,
|
||||
@@ -53,6 +54,8 @@ export abstract class UmbBlockEntryContext<
|
||||
|
||||
#contentKey?: string;
|
||||
|
||||
readonly #localize = new UmbLocalizationController(this);
|
||||
|
||||
#pathAddendum = new UmbRoutePathAddendumContext(this);
|
||||
#variantId = new UmbClassState<UmbVariantId | undefined>(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();
|
||||
|
||||
Reference in New Issue
Block a user