From a551ef4f3c5b828c78744d3fe7b9d47dd58e8915 Mon Sep 17 00:00:00 2001 From: Erik <11491369+kebbet@users.noreply.github.com> Date: Wed, 8 Dec 2021 16:59:27 +0100 Subject: [PATCH 1/4] Remove text domain, set string once. Use sprintf() to combine the string with the $label. --- .../block-library/src/navigation-submenu/index.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/navigation-submenu/index.php b/packages/block-library/src/navigation-submenu/index.php index c0fdbfa271cfa..bbcc1f576dbc0 100644 --- a/packages/block-library/src/navigation-submenu/index.php +++ b/packages/block-library/src/navigation-submenu/index.php @@ -188,6 +188,12 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { ); } + $arialabel = sprintf( + /* translators: button label name */ + __( '%s submenu' ), + $label + ); + $html = '
  • '; // If Submenus open on hover, we render an anchor tag with attributes. @@ -226,11 +232,11 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { if ( $show_submenu_indicators ) { // The submenu icon is rendered in a button here // so that there's a clickable elment to open the submenu. - $html .= ''; + $html .= ''; } } else { // If menus open on click, we render the parent as a button. - $html .= ''; } else { $markup .= '' . $title . ''; @@ -186,7 +191,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click, if ( isset( $page['children'] ) ) { if ( $is_navigation_child && $show_submenu_icons && ! $open_submenus_on_click ) { - $markup .= ''; } From 001fbad50fc92cc5eeef3be016bb67bf84917b2f Mon Sep 17 00:00:00 2001 From: Erik <11491369+kebbet@users.noreply.github.com> Date: Sat, 11 Dec 2021 14:41:28 +0100 Subject: [PATCH 3/4] Update variable name and translator text. Thanks for feedback! --- packages/block-library/src/page-list/index.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/page-list/index.php b/packages/block-library/src/page-list/index.php index 8108f4471f986..0d5728c994180 100644 --- a/packages/block-library/src/page-list/index.php +++ b/packages/block-library/src/page-list/index.php @@ -173,9 +173,9 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click, } } - $title = wp_kses( $page['title'], wp_kses_allowed_html( 'post' ) ); - $arialabel = sprintf( - /* translators: button label name */ + $title = wp_kses( $page['title'], wp_kses_allowed_html( 'post' ) ); + $aria_label = sprintf( + /* translators: Accessibility text. %s: Parent page title. */ __( '%s submenu' ), $title ); @@ -183,7 +183,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click, $markup .= '
  • '; if ( isset( $page['children'] ) && $is_navigation_child && $open_submenus_on_click ) { - $markup .= ''; } else { $markup .= '' . $title . ''; @@ -191,7 +191,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click, if ( isset( $page['children'] ) ) { if ( $is_navigation_child && $show_submenu_icons && ! $open_submenus_on_click ) { - $markup .= ''; } From 4869f62d0ddded8df19eeaec4edf51c2bb4d7d35 Mon Sep 17 00:00:00 2001 From: Erik <11491369+kebbet@users.noreply.github.com> Date: Sat, 11 Dec 2021 14:44:06 +0100 Subject: [PATCH 4/4] Update variable name and translator comment. Thanks for feedback! --- packages/block-library/src/navigation-submenu/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/navigation-submenu/index.php b/packages/block-library/src/navigation-submenu/index.php index bbcc1f576dbc0..60485079897ca 100644 --- a/packages/block-library/src/navigation-submenu/index.php +++ b/packages/block-library/src/navigation-submenu/index.php @@ -188,8 +188,8 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { ); } - $arialabel = sprintf( - /* translators: button label name */ + $aria_label = sprintf( + /* translators: Accessibility text. %s: Parent page title. */ __( '%s submenu' ), $label ); @@ -232,11 +232,11 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { if ( $show_submenu_indicators ) { // The submenu icon is rendered in a button here // so that there's a clickable elment to open the submenu. - $html .= ''; + $html .= ''; } } else { // If menus open on click, we render the parent as a button. - $html .= '