當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。