Python gettext._translations() Examples
The following are 30
code examples of gettext._translations().
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
gettext
, or try the search function
.
Example #1
Source File: test_gettext.py From CTFCrackTools with GNU General Public License v3.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 Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def setUp(self): if not os.path.isdir(LOCALEDIR): os.makedirs(LOCALEDIR) with open(MOFILE, 'wb') as fp: fp.write(base64.decodebytes(GNU_MO_DATA)) with open(MOFILE_BAD_MAJOR_VERSION, 'wb') as fp: fp.write(base64.decodebytes(GNU_MO_DATA_BAD_MAJOR_VERSION)) with open(MOFILE_BAD_MINOR_VERSION, 'wb') as fp: fp.write(base64.decodebytes(GNU_MO_DATA_BAD_MINOR_VERSION)) with open(UMOFILE, 'wb') as fp: fp.write(base64.decodebytes(UMO_DATA)) with open(MMOFILE, 'wb') as fp: fp.write(base64.decodebytes(MMO_DATA)) self.env = support.EnvironmentVarGuard() self.env['LANGUAGE'] = 'xx' gettext._translations.clear()
Example #3
Source File: test_gettext.py From gcblue with BSD 3-Clause "New" or "Revised" 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 #4
Source File: test_gettext.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.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 #5
Source File: test_gettext.py From CTFCrackTools-V2 with GNU General Public License v3.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 #6
Source File: language_handler.py From yugioh-game with MIT License | 6 votes |
def reload(self): backup_cards = self.all_primary_cards backup_languages = self.languages for l in self.languages.keys(): self.languages[l]['db'].close() self.languages = dict() try: for l in backup_languages.keys(): self.add(l, backup_languages[l]['short'], backup_languages[l]['path']) gettext._translations = dict() self.set_primary_language(self.primary_language) return True except LanguageError as e: self.languages = backup_languages self.all_primary_cards = backup_cards return str(e)
Example #7
Source File: test_gettext.py From ironpython3 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 #8
Source File: test_gettext.py From Fluid-Designer with GNU General Public License v3.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 #9
Source File: test_gettext.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def setUp(self): if not os.path.isdir(LOCALEDIR): os.makedirs(LOCALEDIR) with open(MOFILE, 'wb') as fp: fp.write(base64.decodebytes(GNU_MO_DATA)) with open(MOFILE_BAD_MAJOR_VERSION, 'wb') as fp: fp.write(base64.decodebytes(GNU_MO_DATA_BAD_MAJOR_VERSION)) with open(MOFILE_BAD_MINOR_VERSION, 'wb') as fp: fp.write(base64.decodebytes(GNU_MO_DATA_BAD_MINOR_VERSION)) with open(UMOFILE, 'wb') as fp: fp.write(base64.decodebytes(UMO_DATA)) with open(MMOFILE, 'wb') as fp: fp.write(base64.decodebytes(MMO_DATA)) self.env = support.EnvironmentVarGuard() self.env['LANGUAGE'] = 'xx' gettext._translations.clear()
Example #10
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 #11
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 #12
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 #13
Source File: test_autoreload.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_resets_gettext(self): gettext._translations = {'foo': 'bar'} autoreload.reset_translations() self.assertEqual(gettext._translations, {})
Example #14
Source File: test_autoreload.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_resets_trans_real(self): trans_real._translations = {'foo': 'bar'} trans_real._default = 1 trans_real._active = False autoreload.reset_translations() self.assertEqual(trans_real._translations, {}) self.assertIsNone(trans_real._default) self.assertIsInstance(trans_real._active, _thread._local)
Example #15
Source File: test_autoreload.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def tearDown(self): gettext._translations = self.gettext_translations trans_real._translations = self.trans_real_translations
Example #16
Source File: test_autoreload.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def setUp(self): self.gettext_translations = gettext._translations.copy() self.trans_real_translations = trans_real._translations.copy()
Example #17
Source File: test_compilation.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def setUp(self): super().setUp() gettext_module._translations = {} # flush cache or test will be useless
Example #18
Source File: test_gettext.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 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 #19
Source File: test_gettext.py From CTFCrackTools with GNU General Public License v3.0 | 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 #20
Source File: autoreload.py From openhgsenti with Apache License 2.0 | 5 votes |
def reset_translations(): import gettext from django.utils.translation import trans_real gettext._translations = {} trans_real._translations = {} trans_real._default = None trans_real._active = threading.local()
Example #21
Source File: test_gettext.py From gcblue with BSD 3-Clause "New" or "Revised" 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 #22
Source File: autoreload.py From python2017 with MIT License | 5 votes |
def reset_translations(): import gettext from django.utils.translation import trans_real gettext._translations = {} trans_real._translations = {} trans_real._default = None trans_real._active = threading.local()
Example #23
Source File: autoreload.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def reset_translations(): import gettext from django.utils.translation import trans_real gettext._translations = {} trans_real._translations = {} trans_real._default = None trans_real._active = threading.local()
Example #24
Source File: autoreload.py From python with Apache License 2.0 | 5 votes |
def reset_translations(): import gettext from django.utils.translation import trans_real gettext._translations = {} trans_real._translations = {} trans_real._default = None trans_real._active = threading.local()
Example #25
Source File: autoreload.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
def reset_translations(): import gettext from django.utils.translation import trans_real gettext._translations = {} trans_real._translations = {} trans_real._default = None trans_real._active = threading.local()
Example #26
Source File: test_gettext.py From ironpython3 with Apache License 2.0 | 5 votes |
def setUp(self): if not os.path.isdir(LOCALEDIR): os.makedirs(LOCALEDIR) with open(MOFILE, 'wb') as fp: fp.write(base64.decodebytes(GNU_MO_DATA)) with open(UMOFILE, 'wb') as fp: fp.write(base64.decodebytes(UMO_DATA)) with open(MMOFILE, 'wb') as fp: fp.write(base64.decodebytes(MMO_DATA)) self.env = support.EnvironmentVarGuard() self.env['LANGUAGE'] = 'xx' gettext._translations.clear()
Example #27
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 #28
Source File: test_gettext.py From BinderFilter 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 #29
Source File: autoreload.py From bioforum with MIT License | 5 votes |
def reset_translations(): import gettext from django.utils.translation import trans_real gettext._translations = {} trans_real._translations = {} trans_real._default = None trans_real._active = threading.local()
Example #30
Source File: test_gettext.py From ironpython2 with Apache License 2.0 | 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()