From f77225efdaf916eab507eab33615264d43c0ef6b Mon Sep 17 00:00:00 2001 From: yogeshbhutkar Date: Mon, 30 Dec 2024 10:53:29 +0530 Subject: [PATCH] i18n: make example translatable in `table-of-contents` --- .../src/table-of-contents/block.json | 52 ------------------ .../src/table-of-contents/index.js | 53 +++++++++++++++++++ 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/packages/block-library/src/table-of-contents/block.json b/packages/block-library/src/table-of-contents/block.json index 5eb6e729d3f03e..68266166080bbd 100644 --- a/packages/block-library/src/table-of-contents/block.json +++ b/packages/block-library/src/table-of-contents/block.json @@ -62,57 +62,5 @@ } } }, - "example": { - "innerBlocks": [ - { - "name": "core/heading", - "attributes": { - "level": 2, - "content": "Heading" - } - }, - { - "name": "core/heading", - "attributes": { - "level": 3, - "content": "Subheading" - } - }, - { - "name": "core/heading", - "attributes": { - "level": 2, - "content": "Heading" - } - }, - { - "name": "core/heading", - "attributes": { - "level": 3, - "content": "Subheading" - } - } - ], - "attributes": { - "headings": [ - { - "content": "Heading", - "level": 2 - }, - { - "content": "Subheading", - "level": 3 - }, - { - "content": "Heading", - "level": 2 - }, - { - "content": "Subheading", - "level": 3 - } - ] - } - }, "style": "wp-block-table-of-contents" } diff --git a/packages/block-library/src/table-of-contents/index.js b/packages/block-library/src/table-of-contents/index.js index 408538a7dcadbd..ff1b658966f19f 100644 --- a/packages/block-library/src/table-of-contents/index.js +++ b/packages/block-library/src/table-of-contents/index.js @@ -1,6 +1,7 @@ /** * WordPress dependencies */ +import { __ } from '@wordpress/i18n'; import { tableOfContents as icon } from '@wordpress/icons'; /** @@ -19,6 +20,58 @@ export const settings = { icon, edit, save, + example: { + innerBlocks: [ + { + name: 'core/heading', + attributes: { + level: 2, + content: __( 'Heading' ), + }, + }, + { + name: 'core/heading', + attributes: { + level: 3, + content: __( 'Subheading' ), + }, + }, + { + name: 'core/heading', + attributes: { + level: 2, + content: __( 'Heading' ), + }, + }, + { + name: 'core/heading', + attributes: { + level: 3, + content: __( 'Subheading' ), + }, + }, + ], + attributes: { + headings: [ + { + content: __( 'Heading' ), + level: 2, + }, + { + content: __( 'Subheading' ), + level: 3, + }, + { + content: __( 'Heading' ), + level: 2, + }, + { + content: __( 'Subheading' ), + level: 3, + }, + ], + }, + }, }; export const init = () => initBlock( { name, metadata, settings } );