Python __builtin__.gettext() Examples
The following are 30
code examples of __builtin__.gettext().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
__builtin__
, or try the search function
.
Example #1
Source File: test_gettext.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_cache(self): self.localedir = os.curdir self.mofile = MOFILE self.assertEqual(len(gettext._translations), 0) t = gettext.translation('gettext', self.localedir) self.assertEqual(len(gettext._translations), 1) t = gettext.translation('gettext', self.localedir, class_=DummyGNUTranslations) self.assertEqual(len(gettext._translations), 2) self.assertEqual(t.__class__, DummyGNUTranslations) # Calling it again doesn't add to the cache t = gettext.translation('gettext', self.localedir, class_=DummyGNUTranslations) self.assertEqual(len(gettext._translations), 2) self.assertEqual(t.__class__, DummyGNUTranslations)
Example #2
Source File: test_gettext.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_the_alternative_interface(self): eq = self.assertEqual # test the alternative interface with open(self.mofile, 'rb') as fp: t = gettext.GNUTranslations(fp) # Install the translation object t.install() eq(_('nudge nudge'), 'wink wink') # Try unicode return type t.install(unicode=True) eq(_('mullusk'), 'bacon') # Test installation of other methods import __builtin__ t.install(unicode=True, names=["gettext", "lgettext"]) eq(_, t.ugettext) eq(__builtin__.gettext, t.ugettext) eq(lgettext, t.lgettext) del __builtin__.gettext del __builtin__.lgettext
Example #3
Source File: test_gettext.py From oss-ftp with MIT License | 6 votes |
def test_the_alternative_interface(self): eq = self.assertEqual # test the alternative interface with open(self.mofile, 'rb') as fp: t = gettext.GNUTranslations(fp) # Install the translation object t.install() eq(_('nudge nudge'), 'wink wink') # Try unicode return type t.install(unicode=True) eq(_('mullusk'), 'bacon') # Test installation of other methods import __builtin__ t.install(unicode=True, names=["gettext", "lgettext"]) eq(_, t.ugettext) eq(__builtin__.gettext, t.ugettext) eq(lgettext, t.lgettext) del __builtin__.gettext del __builtin__.lgettext
Example #4
Source File: test_gettext.py From oss-ftp with MIT License | 6 votes |
def test_cache(self): self.localedir = os.curdir self.mofile = MOFILE self.assertEqual(len(gettext._translations), 0) t = gettext.translation('gettext', self.localedir) self.assertEqual(len(gettext._translations), 1) t = gettext.translation('gettext', self.localedir, class_=DummyGNUTranslations) self.assertEqual(len(gettext._translations), 2) self.assertEqual(t.__class__, DummyGNUTranslations) # Calling it again doesn't add to the cache t = gettext.translation('gettext', self.localedir, class_=DummyGNUTranslations) self.assertEqual(len(gettext._translations), 2) self.assertEqual(t.__class__, DummyGNUTranslations)
Example #5
Source File: test_gettext.py From BinderFilter with MIT License | 6 votes |
def test_cache(self): self.localedir = os.curdir self.mofile = MOFILE self.assertEqual(len(gettext._translations), 0) t = gettext.translation('gettext', self.localedir) self.assertEqual(len(gettext._translations), 1) t = gettext.translation('gettext', self.localedir, class_=DummyGNUTranslations) self.assertEqual(len(gettext._translations), 2) self.assertEqual(t.__class__, DummyGNUTranslations) # Calling it again doesn't add to the cache t = gettext.translation('gettext', self.localedir, class_=DummyGNUTranslations) self.assertEqual(len(gettext._translations), 2) self.assertEqual(t.__class__, DummyGNUTranslations)
Example #6
Source File: test_gettext.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_the_alternative_interface(self): eq = self.assertEqual # test the alternative interface with open(self.mofile, 'rb') as fp: t = gettext.GNUTranslations(fp) # Install the translation object t.install() eq(_('nudge nudge'), 'wink wink') # Try unicode return type t.install(unicode=True) eq(_('mullusk'), 'bacon') # Test installation of other methods import __builtin__ t.install(unicode=True, names=["gettext", "lgettext"]) eq(_, t.ugettext) eq(__builtin__.gettext, t.ugettext) eq(lgettext, t.lgettext) del __builtin__.gettext del __builtin__.lgettext
Example #7
Source File: test_gettext.py From BinderFilter with MIT License | 6 votes |
def test_the_alternative_interface(self): eq = self.assertEqual # test the alternative interface with open(self.mofile, 'rb') as fp: t = gettext.GNUTranslations(fp) # Install the translation object t.install() eq(_('nudge nudge'), 'wink wink') # Try unicode return type t.install(unicode=True) eq(_('mullusk'), 'bacon') # Test installation of other methods import __builtin__ t.install(unicode=True, names=["gettext", "lgettext"]) eq(_, t.ugettext) eq(__builtin__.gettext, t.ugettext) eq(lgettext, t.lgettext) del __builtin__.gettext del __builtin__.lgettext
Example #8
Source File: test_gettext.py From oss-ftp with MIT License | 5 votes |
def test_multiline_strings(self): eq = self.assertEqual # multiline strings eq(self._('''This module provides internationalization and localization support for your Python programs by providing an interface to the GNU gettext message catalog library.'''), '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH trggrkg zrffntr pngnybt yvoenel.''')
Example #9
Source File: test_gettext.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_fr(self): eq = self.assertEqual f = gettext.c2py('n>1') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "00111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
Example #10
Source File: test_gettext.py From oss-ftp with MIT License | 5 votes |
def test_plural_forms1(self): eq = self.assertEqual x = gettext.ngettext('There is %s file', 'There are %s files', 1) eq(x, 'Hay %s fichero') x = gettext.ngettext('There is %s file', 'There are %s files', 2) eq(x, 'Hay %s ficheros')
Example #11
Source File: test_gettext.py From oss-ftp with MIT License | 5 votes |
def test_plural_forms2(self): eq = self.assertEqual with open(self.mofile, 'rb') as fp: t = gettext.GNUTranslations(fp) x = t.ngettext('There is %s file', 'There are %s files', 1) eq(x, 'Hay %s fichero') x = t.ngettext('There is %s file', 'There are %s files', 2) eq(x, 'Hay %s ficheros')
Example #12
Source File: test_gettext.py From oss-ftp with MIT License | 5 votes |
def test_hu(self): eq = self.assertEqual f = gettext.c2py('0') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
Example #13
Source File: test_gettext.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_multiline_strings(self): eq = self.assertEqual # multiline strings eq(self._('''This module provides internationalization and localization support for your Python programs by providing an interface to the GNU gettext message catalog library.'''), '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH trggrkg zrffntr pngnybt yvoenel.''')
Example #14
Source File: test_gettext.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp(self): GettextBaseTest.setUp(self) self.localedir = os.curdir self.mofile = MOFILE gettext.install('gettext', self.localedir)
Example #15
Source File: test_gettext.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_multiline_strings(self): eq = self.assertEqual # multiline strings eq(_('''This module provides internationalization and localization support for your Python programs by providing an interface to the GNU gettext message catalog library.'''), '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH trggrkg zrffntr pngnybt yvoenel.''')
Example #16
Source File: test_gettext.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp(self): GettextBaseTest.setUp(self) self.localedir = os.curdir # Set up the bindings gettext.bindtextdomain('gettext', self.localedir) gettext.textdomain('gettext') # For convenience self._ = gettext.gettext
Example #17
Source File: test_gettext.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_textdomain(self): self.assertEqual(gettext.textdomain(), 'gettext')
Example #18
Source File: test_gettext.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_plural_forms2(self): eq = self.assertEqual with open(self.mofile, 'rb') as fp: t = gettext.GNUTranslations(fp) x = t.ngettext('There is %s file', 'There are %s files', 1) eq(x, 'Hay %s fichero') x = t.ngettext('There is %s file', 'There are %s files', 2) eq(x, 'Hay %s ficheros')
Example #19
Source File: test_gettext.py From oss-ftp with MIT License | 5 votes |
def test_gd(self): eq = self.assertEqual f = gettext.c2py('n==1 ? 0 : n==2 ? 1 : 2') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
Example #20
Source File: test_gettext.py From oss-ftp with MIT License | 5 votes |
def test_textdomain(self): self.assertEqual(gettext.textdomain(), 'gettext')
Example #21
Source File: test_gettext.py From oss-ftp with MIT License | 5 votes |
def setUp(self): GettextBaseTest.setUp(self) self.localedir = os.curdir # Set up the bindings gettext.bindtextdomain('gettext', self.localedir) gettext.textdomain('gettext') # For convenience self._ = gettext.gettext
Example #22
Source File: test_gettext.py From oss-ftp with MIT License | 5 votes |
def test_multiline_strings(self): eq = self.assertEqual # multiline strings eq(_('''This module provides internationalization and localization support for your Python programs by providing an interface to the GNU gettext message catalog library.'''), '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH trggrkg zrffntr pngnybt yvoenel.''')
Example #23
Source File: test_gettext.py From oss-ftp with MIT License | 5 votes |
def setUp(self): GettextBaseTest.setUp(self) self.localedir = os.curdir self.mofile = MOFILE gettext.install('gettext', self.localedir)
Example #24
Source File: test_gettext.py From oss-ftp with MIT License | 5 votes |
def setUp(self): if not os.path.isdir(LOCALEDIR): os.makedirs(LOCALEDIR) with open(MOFILE, 'wb') as fp: fp.write(base64.decodestring(GNU_MO_DATA)) with open(UMOFILE, 'wb') as fp: fp.write(base64.decodestring(UMO_DATA)) with open(MMOFILE, 'wb') as fp: fp.write(base64.decodestring(MMO_DATA)) self.env = test_support.EnvironmentVarGuard() self.env['LANGUAGE'] = 'xx' gettext._translations.clear()
Example #25
Source File: test_gettext.py From BinderFilter with MIT License | 5 votes |
def setUp(self): GettextBaseTest.setUp(self) with open(MMOFILE, 'rb') as fp: try: self.t = gettext.GNUTranslations(fp) except: self.tearDown() raise
Example #26
Source File: test_gettext.py From BinderFilter with MIT License | 5 votes |
def setUp(self): GettextBaseTest.setUp(self) with open(UMOFILE, 'rb') as fp: self.t = gettext.GNUTranslations(fp) self._ = self.t.ugettext
Example #27
Source File: test_gettext.py From BinderFilter with MIT License | 5 votes |
def test_security(self): raises = self.assertRaises # Test for a dangerous expression raises(ValueError, gettext.c2py, "os.chmod('/etc/passwd',0777)")
Example #28
Source File: test_gettext.py From BinderFilter with MIT License | 5 votes |
def test_sl(self): eq = self.assertEqual f = gettext.c2py('n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "30122333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333012233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333")
Example #29
Source File: test_gettext.py From BinderFilter with MIT License | 5 votes |
def test_ru(self): eq = self.assertEqual f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "20111222222222222222201112222220111222222011122222201112222220111222222011122222201112222220111222222011122222222222222220111222222011122222201112222220111222222011122222201112222220111222222011122222")
Example #30
Source File: test_gettext.py From BinderFilter with MIT License | 5 votes |
def test_lt(self): eq = self.assertEqual f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2') s = ''.join([ str(f(x)) for x in range(200) ]) eq(s, "20111111112222222222201111111120111111112011111111201111111120111111112011111111201111111120111111112011111111222222222220111111112011111111201111111120111111112011111111201111111120111111112011111111")