Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message: Remove hardcoded content order #2650

Open
3 tasks
querkmachine opened this issue May 27, 2022 · 1 comment
Open
3 tasks

Error message: Remove hardcoded content order #2650

querkmachine opened this issue May 27, 2022 · 1 comment
Labels
error message 🕔 hours A well understood issue which we expect to take less than a day to resolve. localisation nunjucks

Comments

@querkmachine
Copy link
Member

querkmachine commented May 27, 2022

What

Error messages currently contain a fixed content order, which is hardcoded into the component's Nunjucks template. This is composed of a block of visually-hidden text (visuallyHiddenText, defaults to 'Error') followed by a colon (:), a hardcoded space, then the configured error message (html or text).

This prefixes the message with 'error' for screen readers, so that the context of the message announced up-front and is easier to understand.

For example, the component may currently output this text:

<span class="govuk-visually-hidden">Error:</span> Enter an event name 

Why

Having a hardcoded content order can make it more difficult to appropriately localise the string.

In particular, the currently hardcoded colon and space characters are incompatible with certain languages. Some logographic written languages—such as Chinese and Japanese—use a fixed-width colon character that fits better alongside logograms, and don't include a space after it.

<span class="govuk-visually-hidden">错误:</span>输入事件名称
<span class="govuk-visually-hidden">エラー:</span>イベント名を入力してください

Translators may also find that the 'Error' label being visible is more useful to their target users—as red does not indicate incorrectness or danger in all cultures (it symbolises happiness and prosperity in Chinese culture, for example).

Although it is currently possible for services to pass HTML into the error message and remove the initial 'Error:' section by setting visuallyHiddenText to false, we may want to investigate methods of either making visuallyHiddenText work with other languages, incorporating the colon and space into the editable area, or removing the use of a dedicated parameter and hardcoded text in favour of only using the html parameter.

Who needs to work on this

Developers

Who needs to review this

Developers

Done when

  • Investigate methods of making the error message support non-English languages.
  • Make changes to the Nunjucks template and related tests, if we decide to make modifications.
  • Document any changes to Nunjucks parameters.
@querkmachine querkmachine added 🕔 hours A well understood issue which we expect to take less than a day to resolve. error message nunjucks localisation labels May 27, 2022
@querkmachine
Copy link
Member Author

Note: It is already possible to do this by manually specifying the visually-hidden text in the Nunjucks html paramenter and setting visuallyHiddenText to false.

For example:

{{ govukErrorMessage({
  visuallyHiddenText: false,
  html: '<span class="govuk-visually-hidden">错误:</span>输入事件名称'
}) }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error message 🕔 hours A well understood issue which we expect to take less than a day to resolve. localisation nunjucks
Projects
None yet
Development

No branches or pull requests

1 participant