Mailinglist Archive: yast-devel (78 mails)
|< Previous||Next >|
[yast-devel] RFC: fix for displaying bidirectional texts (e.g. mixed ASCII + Arabic)
- From: Ladislav Slezak <lslezak@xxxxxxx>
- Date: Thu, 27 Oct 2011 14:29:12 +0200
- Message-id: <4EA94E98.email@example.com>
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
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
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.
Fortunately Unicode has special controlling characters to explicitly set
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
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
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
an external source and might not be marked for translation, so we need to fix
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.
Appliance department / YaST Developer
190 00 Prague 9 / Czech Republic
tel: +420 284 028 960
--- String.ycp (revision 66607)
+++ String.ycp (working copy)
@@ -1370,5 +1370,37 @@
return mergestring (splitstring (str, chars), glue);
+* Force punctuation symbols to be LTR
+* Punctuation symbols are "weak" in bidirectional texts (their direction
+* depends on the direction of the surrounding text)
+* Useful in bidirectional texts (e.g. mixed English and Arabic parts)
+* to fix broken formatting in some cases (punctuation between LTR and RTL
+* See also
+* http://en.wikipedia.org/wiki/Bi-directional_text#Unicode_support and
+* @param str input string
+* @return string the copy of the input but with forced LTR direction of
punctuation characters (.,-())
+global string ForceLTRPunctuation(string str)
+ // Unicode "LEFT-TO-RIGHT MARK" (U+200E)
+ // explicitly changes the preceding character to LTR direction
+ const string LTRmark = "\342\200\216";
+ string ret = ReplaceWith(str, "(", "(" + LTRmark);
+ ret = ReplaceWith(ret, ")", ")" + LTRmark);
+ ret = ReplaceWith(ret, "-", "-" + LTRmark);
+ ret = ReplaceWith(ret, ".", "." + LTRmark);
+ ret = ReplaceWith(ret, ",", "," + LTRmark);
+ return ret;
/* EOF */
--- joy_dialog.ycp (revision 66607)
+++ joy_dialog.ycp (working copy)
@@ -20,6 +20,7 @@
+ import "String";
@@ -410,7 +411,7 @@
// dialog header - %1: card name (e.g "Soundblaster 16"), %2: card ID
- string caption = sformat(_("Joystick Configuration - %1
(snd-card-%2)"), cardname, card_id);
+ string caption = String::ForceLTRPunctuation(sformat(_("Joystick
Configuration - %1 (snd-card-%2)"), cardname, card_id));
string helptext =
// help text for joystick configuration 1/4
|< Previous||Next >|