Open Bug 763320 Opened 12 years ago Updated 9 years ago

[RTL] Add automatic direction handling for RTL texts in Bugzilla

Categories

(Bugzilla :: User Interface, defect)

defect
Not set
normal

Tracking

()

People

(Reporter: tomer, Unassigned)

Details

(Keywords: rtl)

Attachments

(1 file)

Currently, Bugzilla doesn't support RTL at all, which mean that if we will use Bugzilla for languages such as Hebrew and Arabic, we will get right-to-left text misaligned. The simplest fix would be to change to add dir=rtl to the page skin/template, but this will make LTR text such as English and most other languages to look misaligned on RTL skins. 

I saw that landfill installation is now multi-locale, and this might be soon available on bugzilla.mozilla.org as well. Having this implemented is a most for having RTL locales available on multi-locale Bugzilla installation such as bugzilla.mozilla.org, as well as in other companies and organizations which may want to have both localized interface and English one. 


Example:
1. Hello World
2. שלום עולם

Second line should be displayed inside <p dir="rtl">…</p>, so the digit two should be the rightmost character in the paragraph. 



I have few possible suggested fixes to this issue:
a. Adding dir=rtl into Bugzilla skins – easiest, but would cause problems with mixing languages. 
b. Adding dir=auto into Bugzilla skins – not too difficult, but dir=auto is HTML5 feature, and is intended to input fields and not supported well in other browsers. 
c. Adding direction guessing as an Bugzilla plugin or directly into the core. Each paragraph should be checked before sending to display and setting it as RTL as required. 


I suggest implementing the 3rd item which should not be too difficult.
Hi all,

attached is some Perl code that guesses the directionality of a string based on the first letter that has left or right directionality. It is hereby placed in the public domain. Thanks to the people on Freenode's #perl for some assistance.

I hope it will prove of assistance.

Regards,

-- Shlomi Fish
(In reply to Shlomi Fish from comment #1)
> Created attachment 631759 [details]
> Perl function for guessing the directionality of a string.
Does it deal with strings that doesn't starts with an LTR/RTL characters such as lines that starts with numbers? In these cases we should skip these characters until we find a character with directionality bit set.
(In reply to Tomer Cohen :tomer from comment #2)
> (In reply to Shlomi Fish from comment #1)
> > Created attachment 631759 [details]
> > Perl function for guessing the directionality of a string.
> Does it deal with strings that doesn't starts with an LTR/RTL characters
> such as lines that starts with numbers? In these cases we should skip these
> characters until we find a character with directionality bit set.

What this function does is:

1. Search for the first character that is either Bidi_Class:L or Bidi_Class:R.

2. If no such character was found, return "Neutral".

3. If it was found, then return "Left" if it's Bidi_Class:L and "Right" if it's Bidi_Class:R.

I don't know how well, it will handle strings with leading numbers, because I'm not a Unicode/Bidi expert.
Attachment #631759 - Attachment mime type: application/octet-stream → text/plain
(In reply to Shlomi Fish from comment #3)
> 2. If no such character was found, return "Neutral".
It might be enough to call the function again with text(1..n) so we will have recursive call until we find the first character with a directionality weight, and return Natural only if the whole string is natural.
(In reply to Tomer Cohen :tomer from comment #4)
> (In reply to Shlomi Fish from comment #3)
> > 2. If no such character was found, return "Neutral".
> It might be enough to call the function again with text(1..n) so we will
> have recursive call until we find the first character with a directionality
> weight, and return Natural only if the whole string is natural.

There's no need for that. The function looks in the entire string from start to finish (it uses a regular expression search). If it reports "Neutral", then none of the characters in the string have explicit directionality.

Regards,

-- Shlomi Fish
I see. This makes sense!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: