[yast-devel] RFC: fix for displaying bidirectional texts (e.g. mixed ASCII + Arabic)
Hi all, I'm fixing bug https://bugzilla.novell.com/show_bug.cgi?id=583209 the problem is with displaying a bidirectional text. The dialog label contains Arabic traslation of "Joystick Configuration" which is written right-to-left (RTL) plus normal ASCII text with sound card model (written in LTR direction): sformat(_("Joystick Configuration - %1 (snd-card-%2)"), cardname, card_id); The problem is when the text is rendered on the screen the brackets are broken. See the attached screen shots (there is English and Arabic version, the last screenshot is fixed Arabic). It's caused by the fact that punctuation characters in bidirectional text are "weak". I.e. their direction depends on the direction of the surrounding text and that can cause troubles when one side is LTR and the other one is RTL. (See http://en.wikipedia.org/wiki/Bi-directional_text#Unicode_support) Fortunately Unicode has special controlling characters to explicitly set direction for one or more characters. To fix the problem with the string above I have added new String::ForceLTRPunctuation() function which forces LTR direction on some punctuation characters (,.()-) in the string using "LEFT-TO-RIGHT MARK" Unicode controlling character. See the result in the last attached screenshot. Another solution would be to directly fix the Arabic translation so it contains the LTR mark in it. But I'm not sure if it is possible to put binary values into translated pot file via some escape sequence... And some strings might be read from an external source and might not be marked for translation, so we need to fix them on the fly with the above function anyway... Because I'm not an I18N expert I'm asking here for review of this fix. I think the fix cannot be applied generally to any displayed text, sometimes the default direction might be desired and this would break it. The patch is attached for review. -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE
Dne 27.10.2011 14:29, Ladislav Slezak napsal(a): Oops, the first (English) screenshot was taken by mistake from the latest openSUSE which has slightly different label (missing snd-card-X part) than SP2 version in the following screenshots, but that should not matter... -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On Thu, Oct 27, 2011 at 02:29:12PM +0200, Ladislav Slezak wrote:
Hi all,
I'm fixing bug https://bugzilla.novell.com/show_bug.cgi?id=583209 the problem is with displaying a bidirectional text.
I have tried the attached HTML document in Firefox 7, and it displays the original text correctly, and the LRM-spiced text wrong. I think that yast2-qt and yast2-gtk are wrong. It may be possible to use some better Bidi markup to work around that, but I'd prefer to leave that to the translators of the affected languages, if possible. -- (Martin Vidner (YaST developer http://en.opensuse.org/User:Mvidner Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu
participants (2)
-
Ladislav Slezak
-
Martin Vidner