当前位置: 首页>>代码示例>>Python>>正文


Python __builtin__.gettext方法代码示例

本文整理汇总了Python中__builtin__.gettext方法的典型用法代码示例。如果您正苦于以下问题:Python __builtin__.gettext方法的具体用法?Python __builtin__.gettext怎么用?Python __builtin__.gettext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在__builtin__的用法示例。


在下文中一共展示了__builtin__.gettext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_the_alternative_interface

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
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 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:test_gettext.py

示例2: test_cache

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_gettext.py

示例3: setUp

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
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() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_gettext.py

示例4: test_multiline_strings

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
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.''') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_gettext.py

示例5: test_textdomain

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
def test_textdomain(self):
        self.assertEqual(gettext.textdomain(), 'gettext') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:test_gettext.py

示例6: test_plural_forms1

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
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') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_gettext.py

示例7: test_plural_forms2

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
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')

    # Examples from http://www.gnu.org/software/gettext/manual/gettext.html 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_gettext.py

示例8: test_ja

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
def test_ja(self):
        eq = self.assertEqual
        f = gettext.c2py('0')
        s = ''.join([ str(f(x)) for x in range(200) ])
        eq(s, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_gettext.py

示例9: test_fr

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
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") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_gettext.py

示例10: test_lv

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
def test_lv(self):
        eq = self.assertEqual
        f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2')
        s = ''.join([ str(f(x)) for x in range(200) ])
        eq(s, "20111111111111111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111111111111110111111111011111111101111111110111111111011111111101111111110111111111011111111") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_gettext.py

示例11: test_gd

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
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") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_gettext.py

示例12: test_gd2

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
def test_gd2(self):
        eq = self.assertEqual
        # Tests the combination of parentheses and "?:"
        f = gettext.c2py('n==1 ? 0 : (n==2 ? 1 : 2)')
        s = ''.join([ str(f(x)) for x in range(200) ])
        eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_gettext.py

示例13: test_ro

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
def test_ro(self):
        eq = self.assertEqual
        f = gettext.c2py('n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2')
        s = ''.join([ str(f(x)) for x in range(200) ])
        eq(s, "10111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_gettext.py

示例14: test_ru

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
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") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_gettext.py

示例15: test_cs

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import gettext [as 别名]
def test_cs(self):
        eq = self.assertEqual
        f = gettext.c2py('(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2')
        s = ''.join([ str(f(x)) for x in range(200) ])
        eq(s, "20111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_gettext.py


注:本文中的__builtin__.gettext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。