~duplicity-team/duplicity/0.7-series

« back to all changes in this revision

Viewing changes to testing/overrides/gettext.py

  • Committer: Michael Terry
  • Date: 2014-02-05 02:57:01 UTC
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: michael.terry@canonical.com-20140205025701-dn32wy1sunppkulk
Add test that includes unicode characters to check the gpg prompt

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4; encoding:utf8 -*-
 
2
#
 
3
# Copyright 2014 Michael Terry <mike@mterry.name>
 
4
#
 
5
# This file is part of duplicity.
 
6
#
 
7
# Duplicity is free software; you can redistribute it and/or modify it
 
8
# under the terms of the GNU General Public License as published by the
 
9
# Free Software Foundation; either version 2 of the License, or (at your
 
10
# option) any later version.
 
11
#
 
12
# Duplicity is distributed in the hope that it will be useful, but
 
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
# General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with duplicity; if not, write to the Free Software Foundation,
 
19
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
20
 
 
21
# This is just a small override to the system gettext.py which allows us to
 
22
# always return a string with fancy unicode characters, which will notify us
 
23
# if we ever get a unicode->ascii translation by accident.
 
24
 
 
25
def translation(*args, **kwargs):
 
26
    class Translation:
 
27
        ZWSP = u"​" # ZERO WIDTH SPACE, basically an invisible space separator
 
28
        def install(self, **kwargs):
 
29
            import __builtin__
 
30
            __builtin__.__dict__['_'] = lambda x: x + self.ZWSP
 
31
        def ungettext(self, one, more, n):
 
32
            if n == 1: return one + self.ZWSP
 
33
            else:      return more + self.ZWSP
 
34
    return Translation()