~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/i18n.py

  • Committer: Jonathan Riddell
  • Date: 2011-09-15 10:03:58 UTC
  • mfrom: (6138.2.5 i18n-gettext-strings)
  • mto: This revision was merged to the branch mainline in revision 6143.
  • Revision ID: jriddell@canonical.com-20110915100358-cz5jujhsnb0tac9s
mergeĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import os
27
27
import sys
28
28
 
29
 
_translations = _gettext.NullTranslations()
 
29
_translations = None
30
30
 
31
31
 
32
32
def gettext(message):
61
61
 
62
62
    :returns: concatenated translated message as unicode.
63
63
    """
 
64
    install()
64
65
    paragraphs = message.split(u'\n\n')
65
66
    ugettext = _translations.ugettext
66
67
    # Be careful not to translate the empty string -- it holds the
71
72
def disable_i18n():
72
73
    """Do not allow i18n to be enabled.  Useful for third party users
73
74
    of bzrlib."""
74
 
    global installed
75
 
    installed = lambda: True
 
75
    global _translations
 
76
    _translations = _gettext.NullTranslations()
76
77
 
77
78
 
78
79
def installed():
79
 
    return not isinstance(_translations, _gettext.NullTranslations)
 
80
    """Returns whether translations are in use or not."""
 
81
    return _translations is not None
80
82
 
81
83
 
82
84
def install(lang=None):
 
85
    """Enables gettext translations."""
83
86
    global _translations
84
87
    if installed():
85
88
        return
97
100
 
98
101
 
99
102
def uninstall():
 
103
    """Disables gettext translations."""
100
104
    global _translations
101
 
    _translations = _gettext.NullTranslations()
 
105
    _translations = None
102
106
 
103
107
 
104
108
def _get_locale_dir():