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

Brexit countdown language and direction fix #1790

Merged
merged 2 commits into from
Nov 23, 2020
Merged

Conversation

injms
Copy link
Contributor

@injms injms commented Nov 23, 2020

What

Update the countdown component to check whether a translation is available before setting the language element; and set the direction to ltr.

Why

When used on pages that are in right to left lanuages (such as Arabic) and without a translation available, the countdown displayed the number of days left in reverse.

It was also tagged as being in the page's language even when there was no translation available, which led to the countdown displaying English but being tagged as being in another language.

The translation check is done for the "components.related_navigation.transition.title" key only as I think that it's a reasonable assumption that if the title isn't translated then the text won't be either. Ideally there would be a check for both, but for the moment this will ensure that it is fixed. If and when further languages are added then this should be reassessed.

The text direction can be hard-coded to ltr because there are currently only two translations available for this text - Welsh and English. Both of these languages are left to right.

Visual Changes

Before After
image image

@bevanloon bevanloon temporarily deployed to govuk-publis-countdown--0j8mb7 November 23, 2020 16:12 Inactive
@bevanloon bevanloon temporarily deployed to govuk-publis-countdown--0j8mb7 November 23, 2020 16:20 Inactive
@injms injms force-pushed the countdown-dir-lang-fix branch from ac55c25 to 74acd61 Compare November 23, 2020 16:31
@bevanloon bevanloon temporarily deployed to govuk-publis-countdown--0j8mb7 November 23, 2020 16:31 Inactive
@injms injms force-pushed the countdown-dir-lang-fix branch from 74acd61 to cd1b673 Compare November 23, 2020 16:32
@bevanloon bevanloon temporarily deployed to govuk-publis-countdown--0j8mb7 November 23, 2020 16:33 Inactive
The countdown has the page's language whether or not there was a translation
available - there is now a check in place to make sure that there is a
translation available to see whether a `lang` attribute is needed.

The countdown was inheriting a page's right-to-left direction, which would make
the countdown display the numbers in the wrong order - so 39 became 93. The
`dir` attribute that controls the text direction has been set to `ltr` to avoid
this problem.

The translation helpers were previously being used by the related navigation
component - they've now been moved to the shared helpers and tests have been
added to ensure that they work as expected.
@injms injms force-pushed the countdown-dir-lang-fix branch from cd1b673 to 1fc445c Compare November 23, 2020 16:56
@bevanloon bevanloon temporarily deployed to govuk-publis-countdown--0j8mb7 November 23, 2020 16:56 Inactive
@injms injms marked this pull request as ready for review November 23, 2020 16:57
@injms injms requested a review from alex-ju November 23, 2020 16:57
@injms injms force-pushed the countdown-dir-lang-fix branch from 1fc445c to c7ca70c Compare November 23, 2020 17:26
@bevanloon bevanloon temporarily deployed to govuk-publis-countdown--0j8mb7 November 23, 2020 17:26 Inactive
@injms injms merged commit 10c9f22 into master Nov 23, 2020
@injms injms deleted the countdown-dir-lang-fix branch November 23, 2020 17:36
injms added a commit that referenced this pull request Nov 23, 2020
Includes:
 - Fix Brexit countdown in the contextual sidebar to use appropriate lang and
   text direction ([PR #1790](#1790))
@injms injms mentioned this pull request Nov 23, 2020
injms added a commit that referenced this pull request Nov 23, 2020
Includes:
 - Fix Brexit countdown in the contextual sidebar to use appropriate lang and
   text direction #1790
injms added a commit that referenced this pull request Nov 23, 2020
Includes:
 - Fix Brexit countdown in the contextual sidebar to use appropriate lang and
   text direction (#1790)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants