From 268e9f029e5ce6b31fcee16ee1f7f4cf05bc4633 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 24 Apr 2019 23:21:54 +0200 Subject: [PATCH 1/5] Make a11y string properly localizable --- .../block-library/src/heading/edit.native.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/heading/edit.native.js b/packages/block-library/src/heading/edit.native.js index 5d32ba0b3d574..e06a10b45ffdd 100644 --- a/packages/block-library/src/heading/edit.native.js +++ b/packages/block-library/src/heading/edit.native.js @@ -13,7 +13,7 @@ import { isEmpty } from 'lodash'; /** * WordPress dependencies */ -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; import { Component } from '@wordpress/element'; import { RichText, BlockControls } from '@wordpress/block-editor'; import { createBlock } from '@wordpress/blocks'; @@ -98,13 +98,23 @@ class HeadingEdit extends Component { const tagName = 'h' + level; - const accessibilityLabelLevel = __( 'level' ) + ' ' + level + __( '.' ); - const accessibilityLabelContent = isEmpty( content ) ? __( 'Empty' ) : this.plainTextContent( content ); - return ( From 04ca7bdf93b25da25db28b01c0cd23b60c0914ed Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Thu, 25 Apr 2019 11:53:37 +0300 Subject: [PATCH 2/5] Remove extra . after the content --- packages/block-library/src/heading/edit.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/heading/edit.native.js b/packages/block-library/src/heading/edit.native.js index e06a10b45ffdd..563d150241134 100644 --- a/packages/block-library/src/heading/edit.native.js +++ b/packages/block-library/src/heading/edit.native.js @@ -110,7 +110,7 @@ class HeadingEdit extends Component { ) : /* translators: 1: heading level. 2: heading content. */ sprintf( - __( 'Heading block. Level %s1$s. %2$s.' ), + __( 'Heading block. Level %s1$s. %2$s' ), level, this.plainTextContent( content ) ) From 372236686c44e728c67a82091f6989803d7fafba Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Thu, 25 Apr 2019 13:19:52 +0300 Subject: [PATCH 3/5] Add `accessibility text` to the translators comment --- packages/block-library/src/heading/edit.native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/heading/edit.native.js b/packages/block-library/src/heading/edit.native.js index 563d150241134..eb5228f7bbc28 100644 --- a/packages/block-library/src/heading/edit.native.js +++ b/packages/block-library/src/heading/edit.native.js @@ -103,12 +103,12 @@ class HeadingEdit extends Component { accessible={ ! this.props.isSelected } accessibilityLabel={ isEmpty( content ) ? - /* translators: %s: heading level. */ + /* translators: accessibility text. %s: heading level. */ sprintf( __( 'Heading block. Level %s. Empty.' ), level ) : - /* translators: 1: heading level. 2: heading content. */ + /* translators: accessibility text. 1: heading level. 2: heading content. */ sprintf( __( 'Heading block. Level %s1$s. %2$s' ), level, From bb623cfe7c2a48e1295a7a4dd75817fee4610506 Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Thu, 25 Apr 2019 13:43:30 +0300 Subject: [PATCH 4/5] Fix the wrong parameter --- packages/block-library/src/heading/edit.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/heading/edit.native.js b/packages/block-library/src/heading/edit.native.js index eb5228f7bbc28..166d019938ef0 100644 --- a/packages/block-library/src/heading/edit.native.js +++ b/packages/block-library/src/heading/edit.native.js @@ -110,7 +110,7 @@ class HeadingEdit extends Component { ) : /* translators: accessibility text. 1: heading level. 2: heading content. */ sprintf( - __( 'Heading block. Level %s1$s. %2$s' ), + __( 'Heading block. Level %1$s. %2$s' ), level, this.plainTextContent( content ) ) From c056a9328a39a3840a5dd7487b62d9742a56c753 Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Thu, 25 Apr 2019 15:52:22 +0300 Subject: [PATCH 5/5] Change the position of translator comments --- packages/block-library/src/heading/edit.native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/heading/edit.native.js b/packages/block-library/src/heading/edit.native.js index 166d019938ef0..fb41a50cc10f2 100644 --- a/packages/block-library/src/heading/edit.native.js +++ b/packages/block-library/src/heading/edit.native.js @@ -103,13 +103,13 @@ class HeadingEdit extends Component { accessible={ ! this.props.isSelected } accessibilityLabel={ isEmpty( content ) ? - /* translators: accessibility text. %s: heading level. */ sprintf( + /* translators: accessibility text. %s: heading level. */ __( 'Heading block. Level %s. Empty.' ), level ) : - /* translators: accessibility text. 1: heading level. 2: heading content. */ sprintf( + /* translators: accessibility text. 1: heading level. 2: heading content. */ __( 'Heading block. Level %1$s. %2$s' ), level, this.plainTextContent( content )