當前位置: 首頁>>代碼示例>>Python>>正文


Python trans_real._translations方法代碼示例

本文整理匯總了Python中django.utils.translation.trans_real._translations方法的典型用法代碼示例。如果您正苦於以下問題:Python trans_real._translations方法的具體用法?Python trans_real._translations怎麽用?Python trans_real._translations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.utils.translation.trans_real的用法示例。


在下文中一共展示了trans_real._translations方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: update_installed_apps

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
def update_installed_apps(**kwargs):
    if kwargs['setting'] == 'INSTALLED_APPS':
        # Rebuild any AppDirectoriesFinder instance.
        from django.contrib.staticfiles.finders import get_finder
        get_finder.cache_clear()
        # Rebuild management commands cache
        from django.core.management import get_commands
        get_commands.cache_clear()
        # Rebuild templatetags module cache.
        from django.template.base import get_templatetags_modules
        get_templatetags_modules.cache_clear()
        # Rebuild get_app_template_dirs cache.
        from django.template.utils import get_app_template_dirs
        get_app_template_dirs.cache_clear()
        # Rebuild translations cache.
        from django.utils.translation import trans_real
        trans_real._translations = {} 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:19,代碼來源:signals.py

示例2: merge_translation

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
def merge_translation(self, context):
        """
        Context wrapper which modifies the given language's translation catalog using the i18n service, if found.
        """
        language = get_language()
        i18n_service = context.get('_i18n_service', None)
        if i18n_service:
            # Cache the original translation object to reduce overhead
            if language not in self._translations:
                self._translations[language] = trans_real.DjangoTranslation(language)

            translation = trans_real.translation(language)
            translation.merge(i18n_service)

        yield

        # Revert to original translation object
        if language in self._translations:
            trans_real._translations[language] = self._translations[language]  # pylint: disable=protected-access
            # Re-activate the current language to reset translation caches
            trans_real.activate(language) 
開發者ID:edx,項目名稱:xblock-utils,代碼行數:23,代碼來源:i18n.py

示例3: reset_translations

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
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() 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:9,代碼來源:autoreload.py

示例4: language_changed

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
def language_changed(**kwargs):
    if kwargs['setting'] in {'LANGUAGES', 'LANGUAGE_CODE', 'LOCALE_PATHS'}:
        from django.utils.translation import trans_real
        trans_real._default = None
        trans_real._active = threading.local()
    if kwargs['setting'] in {'LANGUAGES', 'LOCALE_PATHS'}:
        from django.utils.translation import trans_real
        trans_real._translations = {}
        trans_real.check_for_language.cache_clear() 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:11,代碼來源:signals.py

示例5: update_installed_apps

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
def update_installed_apps(**kwargs):
    if kwargs['setting'] == 'INSTALLED_APPS':
        # Rebuild any AppDirectoriesFinder instance.
        from django.contrib.staticfiles.finders import get_finder
        get_finder.cache_clear()
        # Rebuild management commands cache
        from django.core.management import get_commands
        get_commands.cache_clear()
        # Rebuild get_app_template_dirs cache.
        from django.template.utils import get_app_template_dirs
        get_app_template_dirs.cache_clear()
        # Rebuild translations cache.
        from django.utils.translation import trans_real
        trans_real._translations = {} 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:16,代碼來源:signals.py

示例6: __init__

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
def __init__(self, do_translate_node):
        """
        Initialize the ProxyTransNode
        """
        self.do_translate = do_translate_node
        self._translations = {} 
開發者ID:edx,項目名稱:xblock-utils,代碼行數:8,代碼來源:i18n.py

示例7: language_changed

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
def language_changed(**kwargs):
    if kwargs['setting'] in ('LOCALE_PATHS', 'LANGUAGE_CODE'):
        from django.utils.translation import trans_real
        trans_real._default = None
        if kwargs['setting'] == 'LOCALE_PATHS':
            trans_real._translations = {} 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:8,代碼來源:signals.py

示例8: setUp

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
def setUp(self):
        self.gettext_translations = gettext._translations.copy()
        self.trans_real_translations = trans_real._translations.copy() 
開發者ID:nesdis,項目名稱:djongo,代碼行數:5,代碼來源:test_autoreload.py

示例9: tearDown

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
def tearDown(self):
        gettext._translations = self.gettext_translations
        trans_real._translations = self.trans_real_translations 
開發者ID:nesdis,項目名稱:djongo,代碼行數:5,代碼來源:test_autoreload.py

示例10: test_resets_gettext

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
def test_resets_gettext(self):
        gettext._translations = {'foo': 'bar'}
        autoreload.reset_translations()
        self.assertEqual(gettext._translations, {}) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:6,代碼來源:test_autoreload.py

示例11: test_resets_trans_real

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
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) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:10,代碼來源:test_autoreload.py

示例12: test_template_tags_pgettext

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
def test_template_tags_pgettext(self):
        """{% trans %} takes message contexts into account (#14806)."""
        trans_real._active = local()
        trans_real._translations = {}
        with translation.override('de'):
            # Nonexistent context...
            t = Template('{% load i18n %}{% trans "May" context "nonexistent" %}')
            rendered = t.render(Context())
            self.assertEqual(rendered, 'May')

            # Existing context... using a literal
            t = Template('{% load i18n %}{% trans "May" context "month name" %}')
            rendered = t.render(Context())
            self.assertEqual(rendered, 'Mai')
            t = Template('{% load i18n %}{% trans "May" context "verb" %}')
            rendered = t.render(Context())
            self.assertEqual(rendered, 'Kann')

            # Using a variable
            t = Template('{% load i18n %}{% trans "May" context message_context %}')
            rendered = t.render(Context({'message_context': 'month name'}))
            self.assertEqual(rendered, 'Mai')
            t = Template('{% load i18n %}{% trans "May" context message_context %}')
            rendered = t.render(Context({'message_context': 'verb'}))
            self.assertEqual(rendered, 'Kann')

            # Using a filter
            t = Template('{% load i18n %}{% trans "May" context message_context|lower %}')
            rendered = t.render(Context({'message_context': 'MONTH NAME'}))
            self.assertEqual(rendered, 'Mai')
            t = Template('{% load i18n %}{% trans "May" context message_context|lower %}')
            rendered = t.render(Context({'message_context': 'VERB'}))
            self.assertEqual(rendered, 'Kann')

            # Using 'as'
            t = Template('{% load i18n %}{% trans "May" context "month name" as var %}Value: {{ var }}')
            rendered = t.render(Context())
            self.assertEqual(rendered, 'Value: Mai')
            t = Template('{% load i18n %}{% trans "May" as var context "verb" %}Value: {{ var }}')
            rendered = t.render(Context())
            self.assertEqual(rendered, 'Value: Kann') 
開發者ID:nesdis,項目名稱:djongo,代碼行數:43,代碼來源:test_trans.py

示例13: tearDown

# 需要導入模塊: from django.utils.translation import trans_real [as 別名]
# 或者: from django.utils.translation.trans_real import _translations [as 別名]
def tearDown(self):
        trans_real._translations = self._translations
        activate(self._language) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:5,代碼來源:test_percents.py


注:本文中的django.utils.translation.trans_real._translations方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。