Skip to content

Commit d6ce1eb

Browse files
committed
Translate the line a screen reader says before each announcement
@wordpress/a11y writes it at DOM-ready, before the renderer has a locale, so it stayed English in every language. It is written again once the locale is applied, beside the window's title. Fixes #648.
1 parent 8303849 commit d6ce1eb

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎src/renderer/index.jsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,11 @@ async function loadLocale() {
24902490
document.documentElement.lang = applyLocale(reply, { setLocaleData, addFilter });
24912491
document.documentElement.dir = textDirection(_x);
24922492
document.title = __('WordPress Contributor Toolkit');
2493+
// @wordpress/a11y wrote the line a screen reader says before each
2494+
// announcement at DOM-ready, before there was a locale, so it is written
2495+
// again in this one (#648).
2496+
const announcementsIntro = document.getElementById('a11y-speak-intro-text');
2497+
if (announcementsIntro) announcementsIntro.textContent = __('Notifications');
24932498
}
24942499

24952500
// The settings load before the first render too, beside the locale (#560):

‎tests/e2e/journeys/i18n.spec.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ test( 'the first-run screen and the create-site dialog are fully translatable',
8080
await expect( createButton ).toBeVisible( { timeout: 30_000 } );
8181
await expect( page.locator( 'html' ) ).toHaveAttribute( 'lang', 'en-XA' );
8282
await expect( page ).toHaveTitle( pseudoLocalize( 'WordPress Contributor Toolkit' ) );
83+
// The line a screen reader says before each announcement, which
84+
// @wordpress/a11y writes before the locale arrives (#648). It is hidden
85+
// until something is announced, so the scans below never see it.
86+
await expect( page.locator( '#a11y-speak-intro-text' ) ).toHaveText( pseudoLocalize( 'Notifications' ) );
8387

8488
// The window with no site in it, and its footer.
8589
expect( await unwrapped( page.locator( '#root' ) ) ).toEqual( [] );

0 commit comments

Comments
 (0)