Opened 6 years ago

Closed 4 years ago

#6778 closed task (duplicate)

RTL: side (alignment) switching

Reported by: Darlan Owned by:
Priority: normal Milestone:
Component: chat Version: 0.14
Severity: major Keywords: Alignment Arabic Farsi Hebrew LRE LRM LTR RLE RLM RTL Urdu
Cc: Blocked By:
Blocking: OS: Unix

Description (last modified by asterix)

Version: 0.14.0.1 or Version: 0.14.0

1.1) LTR nickname.
1.2) When a sentence is started with an RTL character, Gajim is displaying it from the left side.
1.3) Not correct.

2.1) RTL nickname.
2.2) When a sentence is started with an RTL character, Gajim is displaying it from the right side.
2.3) Correct.

3.1) RTL nickname.
3.2) When a sentence is started with an LTR character, Gajim is displaying it from the right side.
3.3) Not correct

4) The alignment should be in accord to the first character that the user is typing (the content that's being published) and not in accord to the user's nickname

Examples:

1st: The way Pidgin <http://pidgin.im/> handles RTL

2nd: At the Gajim Room at gajim on conference.gajim.org

תגיד, אין יישור נורמלי לימין? ב xchat כל העברית מיושרת לי וכאן זה מפריע..

Attachments (16)

rtll.png (135.1 KB) - added by Darlan 6 years ago.
Asterix, Client: Gajim 0.14.0.1-b69aed0d9adc, System: Debian GNU/Linux 6.0 (squeeze)
תצלום מסך.png (199.5 KB) - added by Darlan 6 years ago.
shimi810, Client: Gajim 0.14.0.1-3af4eeae878a, System: Arch Linux
Pidgin-Gajim.png (108.8 KB) - added by Darlan 6 years ago.
zachary, Client: Pidgin 2.7.9 (libpurple 2.7.9), System: Slackware Linux Slackware 13.1.0
gajim-conference.png (203.9 KB) - added by Darlan 6 years ago.
Darlan, Client: Gajim 0.13.4, System: Salix OS 13.1.2 (Slackware 13.1.0 based)
Leafpad 0.8.17.png (85.7 KB) - added by Darlan 6 years ago.
Leafpad 0.8.17 < http://tarot.freeshell.org/leafpad/>
Pidgin-RTL.png (72.6 KB) - added by Darlan 6 years ago.
Pidgin RTL
2011-01-26-203845_799x654_scrot.png (128.1 KB) - added by Darlan 6 years ago.
Hebrew & RTL
common.c (9.1 KB) - added by Darlan 5 years ago.
/liferea-1.8.0/src/common.c
common.h (5.3 KB) - added by Darlan 5 years ago.
/liferea-1.8.0/src/common.h
gtkconv.c (310.3 KB) - added by Darlan 5 years ago.
/pidgin-2.10.1/pidgin/gtkconv.c
Forcing_alignment_with_U+200F.txt (223 bytes) - added by Darlan 4 years ago.
Realization: forcing alignment with U+200F
RTL_test.txt (2.1 KB) - added by Darlan 4 years ago.
Text with U+200F and U+202B characters -- Good {1} {2} {6}, Bad {3} {4} {5}
RTL_test_5_pass.txt (200 bytes) - added by Darlan 4 years ago.
Fixed {5} by adding U+200F and U+202B characters before every LTR character
U+202B.txt (3 bytes) - added by Darlan 4 years ago.
I think that the U+202B character would be a better choice
Forcing_alignment_with_U+200F_and_.U+202Btxt (516 bytes) - added by Darlan 4 years ago.
A fix for https://trac.gajim.org/attachment/ticket/6778/Forcing_alignment_with_U%2B200F.txt
LTR_fail.gif (15.5 KB) - added by Darlan 4 years ago.
This is a test with mixing RTL characters like א with LTR

Download all attachments as: .zip

Change History (42)

Changed 6 years ago by Darlan

Asterix, Client: Gajim 0.14.0.1-b69aed0d9adc, System: Debian GNU/Linux 6.0 (squeeze)

Changed 6 years ago by Darlan

shimi810, Client: Gajim 0.14.0.1-3af4eeae878a, System: Arch Linux

Changed 6 years ago by Darlan

zachary, Client: Pidgin 2.7.9 (libpurple 2.7.9), System: Slackware Linux Slackware 13.1.0

Changed 6 years ago by Darlan

Darlan, Client: Gajim 0.13.4, System: Salix OS 13.1.2 (Slackware 13.1.0 based)

comment:2 Changed 6 years ago by Darlan

2nd: At the Gajim Room at gajim on conference.gajim.org

(A) Asterix, Client: Gajim 0.14.0.1-b69aed0d9adc, System: Debian GNU/Linux 6.0 (squeeze) <http://trac.gajim.org/attachment/ticket/6778/rtll.png>

(B) shimi810, Client: Gajim 0.14.0.1-3af4eeae878a, System: Arch Linux <http://trac.gajim.org/attachment/ticket/6778/%D7%AA%D7%A6%D7%9C%D7%95%D7%9D%20%D7%9E%D7%A1%D7%9A.png>

(C) Darlan, Client: Gajim 0.13.4, System: Salix OS 13.1.2 (Slackware 13.1.0 based) <http://trac.gajim.org/attachment/ticket/6778/gajim-conference.png>

(D) zachary, Client: Pidgin 2.7.9 (libpurple 2.7.9), System: Slackware Linux Slackware 13.1.0 <http://trac.gajim.org/attachment/ticket/6778/Pidgin-Gajim.png> (Yes, Pidgin is not displaying it correctly)

Last edited 6 years ago by Darlan (previous) (diff)

Changed 6 years ago by Darlan

comment:3 in reply to: ↑ 1 Changed 6 years ago by Darlan

Replying to Darlan:

1st: The way Pidgin < http://pidgin.im/> handles RTL http://trac.gajim.org/attachment/ticket/6778/Pidgin-RTL.png



(05:56:38 PM) Myself is no longer idle.
(05:56:38 PM) Myself is no longer away.
‏‪(05:56:38 PM)‬‏‬ ‪Myself‬‏‬: ‫רון פול 2012 Ron Paul לניצחון!
(05:56:39 PM) Myself has gone away.
(05:56:39 PM) Myself is no longer away.
‏‪(05:56:41 PM)‬‏‬ ‪Myself‬‏‬: ‫רון פול 2012 Ron Paul לניצחון!
(06:01:10 PM) Myself: Ron Paul 2012 רון פול FTW
(06:01:11 PM) Myself: Ron Paul 2012 רון פול FTW
(06:11:12 PM) Myself has gone away.
(06:11:12 PM) Myself has become idle.
(06:11:14 PM) Myself is no longer idle.
(06:11:15 PM) Myself has become idle.
Myself has stopped typing


‏‫‏‫‏‫‫רון פול 2012 Ron Paul לניצחון!
Ron Paul 2012 רון פול FTW



The text displayed correctly with Leafpad text editor http://trac.gajim.org/attachment/ticket/6778/Leafpad%200.8.17.png



Please use Firefox > View > Switch Page Direction



If you can't see this menu entry, enable it with: about:config > bidi.browser.ui > Value: true

Last edited 5 years ago by Darlan (previous) (diff)

comment:4 Changed 6 years ago by asterix

  • Description modified (diff)

Changed 6 years ago by Darlan

Pidgin RTL

Changed 6 years ago by Darlan

Hebrew & RTL

comment:5 Changed 6 years ago by Darlan

3rd

תגיד, אין יישור נורמלי לימין? ב xchat כל העברית מיושרת לי וכאן זה מפריע..

Screenshot: The alignment of the first is wrong and the alignment of the second line is right

http://trac.gajim.org/attachment/ticket/6778/2011-01-26-203845_799x654_scrot.png

comment:7 Changed 6 years ago by Darlan

In case you want more RTL text, see logging of this day: http://www.gajim.org/muc_logs/gajim@conference.gajim.org/2011/01/26.html

comment:8 Changed 5 years ago by Darlan

In regard to: Pidgin-Gajim.png:

http://www.gajim.org/muc_logs/gajim@conference.gajim.org/2011/01/26.html#19:41:55.665383

[19:41:55] <Asterix> Darlan: the latest image shows pidgin does it wrong??
[19:42:27] <Darlan> At the Gajim chat, yes Pidgin is doing it wrong
[19:42:45] <Darlan> but not personal to personal chatting ;)
[19:43:01] <Asterix> strange ...

I bet that it means that Pidgin is patched in this RTL field and Gajim has a better (yet, incomplete) and native support for RTL writings.

comment:9 Changed 5 years ago by Darlan

The request is to force Gajim to invert:

[TIME] [NICK] [MESSAGE]

to:

[MESSAGE] [NICK] [TIME]

I believe that it should be fairly easy since it already reversing to RTL if a line starts with an Arabic or Farsi letter.

P.S the order of events should be taken care of only with translated UI to RTL language

[EVENT] [TIME]

[TIME] [EVENT]

comment:10 follow-up: Changed 5 years ago by asterix

I'm not familiar with RTL at all, so I have absolutly no idea what is correct / incorrect. But that sounds very strange to me to display nickname LTR if it contains RTL chars. And Gajom don't decide to print it right or left, GTK does.

comment:11 in reply to: ↑ 10 Changed 5 years ago by Darlan

Replying to asterix:

But that sounds very strange to me to display nickname LTR if it contains RTL chars.

Because if it isn't and if a message contains LTR and RTL characters then it is very probable that the order of the words will be mixed. Pidgin does it with PM messages.

Copy the following text to a text form and switch its direction (LTR <-> RTL)

AAAA العربية CCCC

AAAA BBBB CCCC

Last edited 5 years ago by Darlan (previous) (diff)

comment:12 follow-up: Changed 5 years ago by asterix

I don't know how to switch direction of a text, but once again I don't know what should be printed if string mizes RTL and LTR chars

comment:13 in reply to: ↑ 12 Changed 5 years ago by Darlan

Replying to asterix:

I don't know how to switch direction of a text

Toggle bidi.browser.ui to true in about:config and use the form context menu, or use Leafpad as show above. There should not be any order modifications, only text side switching.

I don't know what should be printed if string mizes RTL and LTR chars

Send me a patch, whenever you like to work on it, and I will test it.

Is this relevant? http://pygtk.org/docs/pygtk/class-gtkentry.html#method-gtkentry--set-alignment

comment:14 Changed 5 years ago by asterix

I can't do a patch for something I don't know ...

And no, your link is not relevent. It's used to align text left or right, not the direction of the text.

comment:15 Changed 5 years ago by Darlan

Can these files be useful?

Liferea:

$ grep rtl *
common.c:		return ("rtl");
common.c:		return ("rtl");
common.h: * @returns a constant "ltr" (default) or "rtl"
common.h: * @returns a constant "ltr" (default) or "rtl"

Pidgin:

$ grep rtl *
gtkconv.c:	gboolean is_rtl_message = FALSE;
gtkconv.c:	is_rtl_message = purple_markup_is_rtl(message);
gtkconv.c:	if (is_rtl_message)
gtkconv.c:		if (is_rtl_message)
gtkimhtml.c:	gboolean rtl_direction = FALSE;
gtkimhtml.c:					 * direction: rtl
gtkimhtml.c:							rtl_direction = TRUE;
gtkimhtml.c:		if (!rtl_direction)
gtkimhtml.c:	gboolean is_rtl_message = FALSE;
gtkimhtml.c:		is_rtl_message = TRUE;
gtkimhtml.c:		g_string_append(str, "<SPAN style=\"direction:rtl;text-align:right;\">");
gtkimhtml.c:	if (is_rtl_message)
gtkutils.c:	gboolean rtl;
gtkutils.c:	rtl        = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL);
gtkutils.c:		if ((rtl  && needed_width <= space_left) ||
gtkutils.c:		    (!rtl && needed_width >  space_right))
gtkutils.c:		if (rtl)
pidginstock.c:	gboolean rtl;
pidginstock.c:find_icon_file(PidginIconTheme *theme, const gchar *size, SizedStockIcon sized_icon, gboolean rtl)
pidginstock.c:		if (rtl)
pidginstock.c:			file_full = g_build_filename(dir, size, "rtl", file, NULL);
pidginstock.c:	if (rtl)
pidginstock.c:		tmp = g_build_filename("pixmaps", "pidgin", sized_icon.dir, size, "rtl", sized_icon.filename, NULL);
pidginstock.c:	gtk_icon_source_set_direction_wildcarded(source, !sized_icon.rtl);
pidginstock.c:	if (sized_icon.rtl) {

Changed 5 years ago by Darlan

/liferea-1.8.0/src/common.c

Changed 5 years ago by Darlan

/liferea-1.8.0/src/common.h

Changed 5 years ago by Darlan

/pidgin-2.10.1/pidgin/gtkconv.c

comment:16 follow-up: Changed 5 years ago by asterix

no:

  • we're not talking about html
  • you said me pidgin don't do the thing correctly
  • I still don't know what's wrong with Gajim

comment:17 Changed 5 years ago by Darlan

Pidgin isn't doing it correctly in MUCs

If a Latin/LTR (e.g. English) text is mixed with a Semitic/RTL text (e.g. Arabic) in a sentence which starts with RTL characters and the alignment of the text starts from the left then you will not see the text properly.

The following text has been adjusted for the LTR order of trac so it will be easier to perceive it

Instead of visually seeing

ע English עברית العربية

You will see:

עברית العربية English ע

Forcing the order [MESSAGE] [NICK] [TIME] will solve this issue.

comment:18 Changed 4 years ago by Darlan

Someone just set to me information that might help us. There is a character that "is not a printable", it is called U+200F RIGHT-TO-LEFT MARK (RLM).

It can be found with GNOME Character Map (command: charmap) Search > Find > Search: U+200F.

Is it feasible to insert a U+200F RIGHT-TO-LEFT MARK before [TIME] (before everything at a line) every time an RTL character is entered as the first letter of a message?

Changed 4 years ago by Darlan

Realization: forcing alignment with U+200F

comment:19 Changed 4 years ago by Darlan

  • Type changed from defect to enhancement

comment:20 Changed 4 years ago by Darlan

  • Type changed from enhancement to task

Changed 4 years ago by Darlan

Text with U+200F and U+202B characters -- Good {1} {2} {6}, Bad {3} {4} {5}

Changed 4 years ago by Darlan

Fixed {5} by adding U+200F and U+202B characters before every LTR character

Changed 4 years ago by Darlan

I think that the U+202B character would be a better choice

comment:21 Changed 4 years ago by Darlan

Correction: Fixed {5} by adding U+200F or* U+202B characters before every LTR character.

Changed 4 years ago by Darlan

This is a test with mixing RTL characters like א with LTR

comment:22 in reply to: ↑ 16 Changed 4 years ago by Darlan

Replying to asterix:

no:

  • we're not talking about html
  • you said me pidgin don't do the thing correctly
  • I still don't know what's wrong with Gajim

If the time is set to [%H:%M:%S] (time_stamp at ACE) when only digits are being displayed (no AM nor PM) and the nickname is in RTL characters, then the alignment is from Right to Left.

But, when I am writing LTR characters, the alignment is wrong (right to left instead of left to right)

Realization: Set the first character in your nickname to an RTL character.
Make sure that there are only digits in your time_stamp. Write (English words) (RTL characters) (more English words) without the brackets.

See attachment LTR_fail.gif (notice the nicknames and timestamps with AM/PM)

You will be able to notice the problem.

comment:23 Changed 4 years ago by Darlan

We will need these characters in the future:

comment:24 Changed 4 years ago by Darlan

  • Keywords LRE LRM LTR RLE RLM added

comment:25 Changed 4 years ago by Darlan

Some more information Understanding Bidirectional (BIDI) Text in Unicode. Every Unicode Character has BIDI directionality (L or R) assigned to it. I will check and suggest an algorithm for the use of Unicode Control Characters.

comment:26 Changed 4 years ago by Darlan

  • Resolution set to duplicate
  • Status changed from new to closed

Continue at #7284

Note: See TracTickets for help on using tickets.