getodk / central-frontend

Vue.js based frontend for ODK Central
https://docs.getodk.org/central-intro/
Apache License 2.0
32 stars 59 forks source link

Adding an RTL locale #470

Open matthew-white opened 3 years ago

matthew-white commented 3 years ago

We don't have active plans to add an RTL locale, but we may do so at some point. Adding notes here for if/when we do so.

matthew-white commented 3 years ago

What about the direction of numbers? I think that varies even among RTL locales?

Actually, it looks like this might not be the case. Arabic, Farsi, and Hebrew all seem to write numbers with the most significant digit on the left (as in English).

matthew-white commented 3 years ago

Do dates look correct?

Right now, a date/time looks like:

2021/01/01 12:34

For a language written RTL, the numbers will remain LTR (see above), but the order of the date and time will reverse:

2021/01/01 12:34

That seems reasonable to me, so I won't plan to make additional changes unless they're suggested. I do think we should consider internationalizing our dates at some point. Vue I18n has a mechanism to do so, so I don't think it'd be a particularly heavy lift. However, that should probably be done as a separate story.

matthew-white commented 3 years ago

There's been some discussion on the forum that I wanted to link to: https://forum.getodk.org/t/odk-central-is-ready-for-translating/28491/19

As a first step for languages written RTL, we're planning to support RTL text. The layout still wouldn't be RTL, but it seems like even just supporting RTL text would be helpful. I wrote some notes in Slack about what that would entail, which I'll copy here:

Even without changes to Central, there are many cases where RTL text would be displayed in the correct direction. Even if the document direction is LTR, an RTL word will be displayed RTL. An unbroken string of RTL words will also be correctly displayed RTL.

Trouble starts emerging for sentences that are a mix of RTL and LTR, for example, a sentence that contains the word “Central” untranslated, that contains an email address, etc. If you have [start of sentence in Arabic] [“Central” untranslated] [end of sentence in Arabic], then [start of sentence in Arabic] will be displayed to the left of [end of sentence in Arabic], even though individually/internally [start of sentence in Arabic] and [end of sentence in Arabic] will be displayed RTL. That’s because the sentence is analyzed as an LTR sentence with RTL words, even though the sentence is mostly RTL.

Trouble also emerges with punctuation, which will revert to LTR in some cases. For example, the period at the end of a sentence may be incorrectly shown to the right (at the start) of an Arabic sentence.

Specifying the dir attribute on the <html> element would fix these cases. However, the dir attribute also has layout effects, for example, reversing the column order of tables.

It’s not preferred, but there’s also a way to specify the direction using CSS. We could use that to set the direction to RTL for blocks of text like <p>, where the troublesome cases are most likely.

In looking into this, I found this to be a useful resource: https://www.w3.org/International/articles/inline-bidi-markup/uba-basics

I've started working on supporting RTL text. I think I'll be able to look at several items in the checklist above as part of that. However, many items in the checklist will wait until we start working on an RTL layout, including most things related to the dir attribute and CSS logical properties.

Here are a couple of examples of what this will look like. The login page has Arabic text, but that text is still left-aligned as part of an LTR layout:

Login in Arabic

Similarly, here is the "Set up Backups" modal in Arabic:

Set up Backups in Arabic