Improved handling of RTL nicknames in roster. Fixes #4293
If the number of connected resources is appended in parentheses, the appropriate ltr or rtl mark is inserted before, so that the writing direction at the end of the nickname matches the writing direction of the whole displayed string as determined by http://www.unicode.org/reports/tr9/#The_Paragraph_Level
This commit is contained in:
parent
2e1eeae6f1
commit
568e1edd1e
|
@ -5,6 +5,7 @@
|
||||||
## Copyright (C) 2004 Vincent Hanquez <tab AT snarc.org>
|
## Copyright (C) 2004 Vincent Hanquez <tab AT snarc.org>
|
||||||
## Copyright (C) 2004-2007 Yann Leboulanger <asterix AT lagaule.org>
|
## Copyright (C) 2004-2007 Yann Leboulanger <asterix AT lagaule.org>
|
||||||
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
|
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
|
||||||
|
## Copyright (C) 2009 Benjamin Richter <br AT waldteufel-online.net>
|
||||||
##
|
##
|
||||||
## This file is part of Gajim.
|
## This file is part of Gajim.
|
||||||
##
|
##
|
||||||
|
@ -25,6 +26,19 @@ import locale
|
||||||
import gettext
|
import gettext
|
||||||
import os
|
import os
|
||||||
import defs
|
import defs
|
||||||
|
import unicodedata
|
||||||
|
|
||||||
|
def paragraph_direction_mark(text):
|
||||||
|
"""Determine paragraph writing direction according to
|
||||||
|
http://www.unicode.org/reports/tr9/#The_Paragraph_Level
|
||||||
|
|
||||||
|
Returns either Unicode LTR mark or RTL mark."""
|
||||||
|
for c in text:
|
||||||
|
bidi = unicodedata.bidirectional(c)
|
||||||
|
if bidi == 'L': return u'\u200E'
|
||||||
|
elif bidi == 'AL' or bidi == 'R': return u'\u200F'
|
||||||
|
|
||||||
|
return u'\u200E'
|
||||||
|
|
||||||
APP = 'gajim'
|
APP = 'gajim'
|
||||||
DIR = defs.localedir
|
DIR = defs.localedir
|
||||||
|
|
|
@ -1113,7 +1113,9 @@ class RosterWindow:
|
||||||
if c.show not in ('error', 'offline'):
|
if c.show not in ('error', 'offline'):
|
||||||
nb_connected_contact += 1
|
nb_connected_contact += 1
|
||||||
if nb_connected_contact > 1:
|
if nb_connected_contact > 1:
|
||||||
name += ' (' + unicode(nb_connected_contact) + ')'
|
# switch back to default writing direction
|
||||||
|
name += i18n.paragraph_direction_mark(unicode(name))
|
||||||
|
name += u' (%d)' % nb_connected_contact
|
||||||
|
|
||||||
# show (account_name) if there are 2 contact with same jid
|
# show (account_name) if there are 2 contact with same jid
|
||||||
# in merged mode
|
# in merged mode
|
||||||
|
|
Loading…
Reference in New Issue