~ubuntu-branches/ubuntu/lucid/gajim/lucid-security

« back to all changes in this revision

Viewing changes to src/common/i18n.py

  • Committer: Maia Kozheva
  • Date: 2009-11-25 08:32:36 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: sikon@maia-desktop-20091125083236-hkxrujhn3amehuve
Merged new upstream release 0.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
## Copyright (C) 2004 Vincent Hanquez <tab AT snarc.org>
6
6
## Copyright (C) 2004-2007 Yann Leboulanger <asterix AT lagaule.org>
7
7
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
 
8
## Copyright (C) 2009 Benjamin Richter <br AT waldteufel-online.net>
8
9
##
9
10
## This file is part of Gajim.
10
11
##
25
26
import gettext
26
27
import os
27
28
import defs
 
29
import unicodedata
 
30
 
 
31
def paragraph_direction_mark(text):
 
32
        """
 
33
        Determine paragraph writing direction according to
 
34
        http://www.unicode.org/reports/tr9/#The_Paragraph_Level
 
35
        
 
36
        Returns either Unicode LTR mark or RTL mark.
 
37
        """
 
38
        for char in text:
 
39
                bidi = unicodedata.bidirectional(char)
 
40
                if bidi == 'L':
 
41
                        return u'\u200E'
 
42
                elif bidi == 'AL' or bidi == 'R':
 
43
                        return u'\u200F'
 
44
 
 
45
        return u'\u200E'
28
46
 
29
47
APP = 'gajim'
30
48
DIR = defs.localedir
56
74
        # so we must use as:
57
75
        # s = Q_('?vcard:Unknown')
58
76
        # widget.set_text(s)
59
 
        # Q_() removes the ?vcard: 
 
77
        # Q_() removes the ?vcard:
60
78
        # but gettext while parsing the file detects ?vcard:Unknown as a whole string.
61
79
        # translator can either put the ?vcard: part or no (easier for him or her to no)
62
80
        # nothing fails
68
86
def ngettext(s_sing, s_plural, n, replace_sing = None, replace_plural = None):
69
87
        '''use as:
70
88
        i18n.ngettext('leave room %s', 'leave rooms %s', len(rooms), 'a', 'a, b, c')
71
 
        
 
89
 
72
90
        in other words this is a hack to ngettext() to support %s %d etc..
73
91
        '''
74
92
        text = _translation.ungettext(s_sing, s_plural, n)