alphagov / govuk-design-system-backlog

GOV.UK Design System Community Backlog
31 stars 2 forks source link

Right-to-left (RTL) language support #252

Open querkmachine opened 2 years ago

querkmachine commented 2 years ago

What

Add support for right-to-left (RTL) languages to GOV.UK Frontend components.

Why

A number of pages on GOV.UK are made available in RTL languages, however they tend to insert RTL content into the same layout used by left-to-right (LTR) languages instead of mirroring the entire interface, as is typical for RTL languages. For example, in RTL languages a right-pointing arrow indicates moving backwards, whereas a left-pointing arrow indicates progress.

RTL languages are currently in use in various areas of GOV.UK. (Google search results are for a rough indication of how widely used each language is.)

GOV.UK's lack of RTL support produces unexpected layouts in situation where RTL languages are already in use (though many of these instances are with publishing components and not Frontend):

There are some situations where RTL language content has only been made available in PDF format, potentially due to restrictions with creating this content in HTML, which creates an accessibility barrier for end users. For example, detention rights are available in English as a HTML page but must be downloaded as a PDF for Arabic, Farsi and Urdu speakers.

querkmachine commented 2 years ago

In an audit of content published on GOV.UK between March 2019 and February 2020 (not public data, sorry!):

paulmsmith commented 2 years ago

I have been thinking about this recently, the time might be approaching to replace the use of floats for the grid layouts and components on GOV.UK.

No doubt this has been discussed already in GDS but using CSS Grid or Flexbox would make this much easier to do and maintain.

Some of the most troublesome parts of handling RTL layouts are starting to go away (as browsers roll out of use). For example, the need to adjust the direction of spacing, such as switching a margin-right to a margin-left, etc can be avoided by using the CSS gap property.

Also "source order" of layout elements is less tricky when using CSS Grid or Flexbox.

I think this is an excellent suggestion and would make GOVUK much more accessible and inclusive. How to achieve this is what will take a lot of thought. I'd be very happy to contribute to any discussions or workshops.

querkmachine commented 2 years ago

Another, possibly complementary, approach would be to embrace the use of Logical Properties and Values, and rewrite our CSS to use logical properties (like start and end) rather than physical ones (left and right).

Although the spec is supported by current versions of all the evergreen browsers, the spec is relatively new, a little unstable, and most people haven't even heard of it, let alone feel comfortable using it. There's a bit of a learning curve if we want to take that route.

paulmsmith commented 2 years ago

Agree I'm looking forward to using logical properties and did some experiments not long ago. I tried using a post-processor to cleverly switch them out whilst generating a fall-back stylesheet for older IEs but I backed out of it slowly because:

  1. It got super complicated fast
  2. I suspected it would introduce an auto-magic box people wouldn't easily be able to debug or trust.