From 2767234963708da6775a7fd125315a59b375a9b1 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Thu, 6 May 2021 19:02:45 +0200 Subject: [PATCH 1/2] Add get title to missing block The block's title is now only translated when is gets registered, for unsupported blocks since they're not registered, title has be explicitly translated. --- .../block-library/src/missing/edit.native.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/missing/edit.native.js b/packages/block-library/src/missing/edit.native.js index db06224a2db25d..38a689aa526273 100644 --- a/packages/block-library/src/missing/edit.native.js +++ b/packages/block-library/src/missing/edit.native.js @@ -21,7 +21,7 @@ import { compose, withPreferredColorScheme } from '@wordpress/compose'; import { coreBlocks } from '@wordpress/block-library'; import { normalizeIconObject } from '@wordpress/blocks'; import { Component } from '@wordpress/element'; -import { __, sprintf } from '@wordpress/i18n'; +import { __, _x, sprintf } from '@wordpress/i18n'; import { help, plugins } from '@wordpress/icons'; import { withSelect, withDispatch } from '@wordpress/data'; import { applyFilters } from '@wordpress/hooks'; @@ -34,6 +34,7 @@ import styles from './style.scss'; // Blocks that can't be edited through the Unsupported block editor identified by their name. const UBE_INCOMPATIBLE_BLOCKS = [ 'core/block' ]; +const I18N_BLOCK_SCHEMA_TITLE = 'block title'; export class UnsupportedBlockEdit extends Component { constructor( props ) { @@ -63,6 +64,18 @@ export class UnsupportedBlockEdit extends Component { } } + getTitle() { + const { originalName } = this.props.attributes; + const blockType = coreBlocks[ originalName ]; + const title = blockType?.metadata.title; + const textdomain = blockType?.metadata.textdomain; + + return title && textdomain + ? // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain + _x( title, I18N_BLOCK_SCHEMA_TITLE, textdomain ) + : originalName; + } + renderHelpIcon() { const infoIconStyle = this.props.getStylesFromColorScheme( styles.infoIcon, @@ -225,7 +238,7 @@ export class UnsupportedBlockEdit extends Component { const { getStylesFromColorScheme, preferredColorScheme } = this.props; const blockType = coreBlocks[ originalName ]; - const title = blockType ? blockType.settings.title : originalName; + const title = this.getTitle(); const titleStyle = getStylesFromColorScheme( styles.unsupportedBlockMessage, styles.unsupportedBlockMessageDark From c144ea6ab9dbe4c3a96f009f7f196bdf3723c04b Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Wed, 12 May 2021 11:37:01 +0200 Subject: [PATCH 2/2] Update react-native-editor changelog --- packages/react-native-editor/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index 7b5750249ed779..50f0a81a4de822 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -13,6 +13,7 @@ For each user feature we should also add a importance categorization label to i - [*] Bottom-sheet: Add custom header [#30291] - [*] Fixes color picker rendering bug when scrolling [#30994] - [*] Add enableCaching param to fetch request on Android [#31186] +- [*] Fix missing title for some unsupported blocks [#31743] ## 1.52.1