Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In right-to-left language(like Arabic and Hebrew),bracket reversed

Now I have a string like (in ltr)

Hebrew text(3)

and when I use dir="rtl" or direction:rtl to redirect the string it actually goes:

מחיר אחד(3)

(actually i entered Hebrew charactor(3) just now it automaticlly became like above↑)

is there any way to make it like

(3)Hebrew text

(using html or css)

like image 817
sleepholic Avatar asked Aug 22 '13 08:08

sleepholic


People also ask

Which language is written from right to left?

Hebrew is one of the languages written from right to left. Ancient Semitic languages like Hebrew and Arabic were chiselled into stones in ancient days. Words and pictographs had to be recorded on a visual medium, such as hard objects, because paper did not exist.

How do I support right-to-left languages like Arabic and Hebrew?

Support right-to-left languages like Arabic and Hebrew by reversing your interface as needed to match the reading direction of the related scripts. When people choose a language for their device — or just your app or game — they expect the interface to adapt in various ways (to learn more, see Localization ).

What is an example of left to right alignment?

For example, if you left-align text with content in the left-to-right (LTR) context, right-align the text to match the content’s mirrored position in the RTL context. Align a paragraph based on its language, not on the current context.

What is right-to-left interface (RTL)?

When people choose a language for their device — or just your app or game — they expect the interface to adapt in various ways (to learn more, see Localization ). System-provided UI frameworks support right-to-left (RTL) by default, enabling system-provided UI components to flip automatically in the RTL context.


2 Answers

You don't need to wrap the bracketed text in a separate span.

Rather, to fix this problem add a RLM control character (‏) after the closing bracket. The RLM character acts as another Hebrew/Arabic character and so the bracket ( which is a weak character) changes its direction and moves to its correct place.

Like so:

<div>מחיר אחד(3)&rlm;</div>

NB: If you set the attribute dir="rtl" on the element - then even the RLM control character is unnecessary.

Like so:

<div dir="rtl">מחיר אחד(3)</div>

CODEPEN (jsFiddle down by me)

This microsoft doc explains the RLM control character along with other similar control characters.

like image 109
Danield Avatar answered Oct 10 '22 03:10

Danield


(updated: thank you rob for clarifying your comment)

this is a little less invasive solution (result in jsFiddle):

<span lang="he" dir="rtl">מחיר אחד<span>(3)</span></span>

It seems the last parentheses is concidered as punctuation and thus treated differently. This article gave me some clarity:

... Note that unlike align="right", the punctuation will also relocated... See Sample RTL Document

In the sample document the same relocation of the last parentheses also occurs within the subtitle "Bidirectional Override (BDO)".

*checked the jsfiddle solution in latest chrome/ff/safari/ie

like image 38
Jaak Kütt Avatar answered Oct 10 '22 05:10

Jaak Kütt