Lines Matching full:gettext
3 import gettext
107 MOFILE = os.path.join(LOCALEDIR, 'gettext.mo')
130 gettext._translations.clear()
149 gettext.install('gettext', self.localedir)
188 gettext message catalog library.'''),
197 t = gettext.GNUTranslations(fp)
206 t.install(names=["gettext", "lgettext"])
207 eq(_, t.gettext)
208 eq(builtins.gettext, t.gettext)
210 del builtins.gettext
219 gettext.bindtextdomain('gettext', self.localedir)
220 gettext.textdomain('gettext')
222 self._ = gettext.gettext
225 self.assertEqual(gettext.bindtextdomain('gettext'), self.localedir)
228 self.assertEqual(gettext.textdomain(), 'gettext')
233 gettext.GNUTranslations(fp)
243 gettext.GNUTranslations(fp)
282 gettext message catalog library.'''),
295 x = gettext.ngettext('There is %s file', 'There are %s files', 1)
297 x = gettext.ngettext('There is %s file', 'There are %s files', 2)
303 t = gettext.GNUTranslations(fp)
309 # Examples from http://www.gnu.org/software/gettext/manual/gettext.html
313 f = gettext.c2py('0')
319 f = gettext.c2py('n != 1')
325 f = gettext.c2py('n>1')
331 f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2')
337 f = gettext.c2py('n==1 ? 0 : n==2 ? 1 : 2')
344 f = gettext.c2py('n==1 ? 0 : (n==2 ? 1 : 2)')
350 f = gettext.c2py('n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2')
356 f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2')
362 …f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2…
368 f = gettext.c2py('(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2')
374 f = gettext.c2py('n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2')
380 f = gettext.c2py('n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3')
386 … f = gettext.c2py('n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5')
393 raises(ValueError, gettext.c2py, "os.chmod('/etc/passwd',0777)")
395 raises(ValueError, gettext.c2py, '"(eval(foo) && ""')
396 raises(ValueError, gettext.c2py, 'f"{os.system(\'sh\')}"')
398 raises(ValueError, gettext.c2py, 'n+'*10000 + 'n')
399 self.assertEqual(gettext.c2py('n+'*100 + 'n')(1), 101)
401 raises(ValueError, gettext.c2py, '('*100 + 'n' + ')'*100)
403 raises(ValueError, gettext.c2py, '('*10000 + 'n' + ')'*10000)
404 self.assertEqual(gettext.c2py('('*20 + 'n' + ')'*20)(1), 1)
408 f = gettext.c2py('n == n == n')
410 f = gettext.c2py('1 < n == n')
412 f = gettext.c2py('n == n < 2')
414 f = gettext.c2py('0 < n < 2')
418 self.assertEqual(gettext.c2py('0123')(1), 123)
427 gettext.c2py(expr)
430 self.assertEqual(gettext.c2py('n?1?2:3:4')(0), 4)
431 self.assertEqual(gettext.c2py('n?1?2:3:4')(1), 2)
432 self.assertEqual(gettext.c2py('n?1:3?4:5')(0), 4)
433 self.assertEqual(gettext.c2py('n?1:3?4:5')(1), 1)
436 f = gettext.c2py('2/n*3')
444 f = gettext.c2py('n != 1')
465 lgettext = gettext.lgettext
466 ldgettext = gettext.ldgettext
469 self.assertEqual(ldgettext('gettext', 'mullusk'), b'bacon')
470 self.assertEqual(ldgettext('gettext', 'spam'), b'spam')
474 t = gettext.GNUTranslations(fp)
480 lgettext = gettext.lgettext
481 ldgettext = gettext.ldgettext
482 saved_codeset = gettext.bind_textdomain_codeset('gettext')
484 gettext.bind_textdomain_codeset('gettext', 'utf-16')
487 self.assertEqual(ldgettext('gettext', 'mullusk'), 'bacon'.encode('utf-16'))
488 self.assertEqual(ldgettext('gettext', 'spam'), 'spam'.encode('utf-16'))
490 del gettext._localecodesets['gettext']
491 gettext.bind_textdomain_codeset('gettext', saved_codeset)
495 t = gettext.GNUTranslations(fp)
502 lngettext = gettext.lngettext
503 ldngettext = gettext.ldngettext
512 x = ldngettext('gettext', 'There is %s file', 'There are %s files', 1)
514 x = ldngettext('gettext', 'There is %s file', 'There are %s files', 2)
516 x = ldngettext('gettext', 'There is %s directory', 'There are %s directories', 1)
518 x = ldngettext('gettext', 'There is %s directory', 'There are %s directories', 2)
523 t = gettext.GNUTranslations(fp)
535 lngettext = gettext.lngettext
536 ldngettext = gettext.ldngettext
537 saved_codeset = gettext.bind_textdomain_codeset('gettext')
539 gettext.bind_textdomain_codeset('gettext', 'utf-16')
548 x = ldngettext('gettext', 'There is %s file', 'There are %s files', 1)
550 x = ldngettext('gettext', 'There is %s file', 'There are %s files', 2)
552 x = ldngettext('gettext', 'There is %s directory', 'There are %s directories', 1)
554 x = ldngettext('gettext', 'There is %s directory', 'There are %s directories', 2)
557 del gettext._localecodesets['gettext']
558 gettext.bind_textdomain_codeset('gettext', saved_codeset)
562 t = gettext.GNUTranslations(fp)
581 t = gettext.GNUTranslations(fp)
588 self.t = gettext.GNUTranslations(fp)
589 self._ = self.t.gettext
603 self.t = gettext.GNUTranslations(fp)
615 class DummyGNUTranslations(gettext.GNUTranslations):
625 self.assertEqual(len(gettext._translations), 0)
627 t = gettext.translation('gettext', self.localedir)
629 self.assertEqual(len(gettext._translations), 1)
631 t = gettext.translation('gettext', self.localedir,
634 self.assertEqual(len(gettext._translations), 2)
639 t = gettext.translation('gettext', self.localedir,
642 self.assertEqual(len(gettext._translations), 2)
649 support.check__all__(self, gettext, blacklist=blacklist)
707 "gettext message catalog library."