electronjs.org-old icon indicating copy to clipboard operation
electronjs.org-old copied to clipboard

fix display of parentheses for right-to-left languages

Open zeke opened this issue 7 years ago • 4 comments

This is a followup to https://github.com/electron/electronjs.org/pull/1254

A few things are still quirky on RTL pages, like parentheses. Here's an example from the Arabic /releases page:

screen shot 2018-05-21 at 9 00 51 pm

Possible ways to solve this:

  • https://stackoverflow.com/questions/5741522/brackets-displays-wrongly-for-right-to-left-display-style
  • ‏ tag
  • http://rtlcss.com
  • https://www.npmjs.com/package/flipcss

zeke avatar May 22 '18 04:05 zeke

Recommendation: add dir="auto" to surrounding section elements, like <section class="page-section" dir="auto">. I think the browser should automatically detect the language of the content of an element with dir="auto" based on the characters used, then select an appropriate direction on a per-section basis. Sections that are still in English will be left-to-right, and fully translated sections in Arabic would be right-to-left.

Bidirectional text in HTML: https://www.w3.org/International/articles/inline-bidi-markup/index Bidirectional text in Unicode: https://www.w3.org/International/articles/inline-bidi-markup/uba-basics

I'll try this out and let y'all know how I go.

snidelyhazel avatar Aug 14 '18 07:08 snidelyhazel

Sounds good, @snidelyhazel! Feel free to open a WIP PR whenever.

zeke avatar Aug 14 '18 17:08 zeke

So I was playing with setting dir="auto" on section elements, and it's not gonna be enough in situations where there's only a partial translation. If one parens is surrounded by the same language on either side, but the other parens is surrounded by two different languages on either side, not even dir="auto" can fix it 'cause neutral characters resolve their directionality according to the surrounding text. Any punctuation that acts as a border for a language transition is gonna be a problem.

Two options for mixed-language text where a parens is bordered by different languages:

  • Explicitly tag directionality. <div dir="rtl">parenthetical text)RTL text)</div>

  • Use a nonprinting character. <div>parenthetical text)RTL text)&rlm;</div>

The latter might be advantageous 'cause it might be more markdown-friendly i.e. translators can include it themselves as needed.

(Technically there's a third option: not to be fussed by mixed-language text.)

snidelyhazel avatar Aug 15 '18 09:08 snidelyhazel

@snidelyhazel thanks again for digging into this. Can you open a pull request that makes some of these exploratory changes? That will make it easy for folks to preview the effects of the change.

zeke avatar Aug 24 '18 16:08 zeke