-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Font size picker: fix translatable strings and accessibility #63810
Copy link
Copy link
Closed
Labels
[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).Changes that impact accessibility and need corresponding review (e.g. markup changes).[Package] Components/packages/components/packages/components[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intendedl10nLocalization and translations best practicesLocalization and translations best practices
Metadata
Metadata
Assignees
Labels
[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).Changes that impact accessibility and need corresponding review (e.g. markup changes).[Package] Components/packages/components/packages/components[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intendedl10nLocalization and translations best practicesLocalization and translations best practices
Type
Fields
Give feedbackNo fields configured for issues without a type.
Description
The font size picker renders some text which comes from a component called
HeaderLabel. The text of this component is meant to communicate the currently selected font size or whether it's a custom size.The default text is
Size. When a size is set, the size name is appended to thte default text e.g.Size medium:gutenberg/packages/components/src/font-size-picker/index.tsx
Lines 131 to 140 in 8df860e
This may work in English. It doesn't work for all languages with gendered nouns. For example, in Italian the noun 'Size' is translated to
Dimensione, which is female. However, all the size adjectives are translated to masculine.We can't blame translators for this. In WordPress, the best practices for l10n recommend to always use full translatable strings and never concatenate strings that may contain variable parts. Something like this:
${ __( 'Size' ) } ${ headerHint || '' }can't be translated correctly and must be avoided. In core, this best practice is implemented pretty well as it's established since ages. In Gutenberg, I see many cases of concatenation that should be all refactored.
The result in the italian translation is:
Only 2 of these 6 tranlations are acceptable:
grandeandmolto grande. The other ones are wrong.Accessibility
The
HeaderLabelcomponent renders a styled<span>element. This element has anaria-labelattribute that just repeats the visible text. Also, using an aria-label on a<span>element is pointless as it's not an interactive control and doesn't have ani ARIA role.Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.