2 # Author: David Goodger <goodger@python.org>
3 # Copyright: This module has been placed in the public domain.
5 # Internationalization details are documented in
6 # <http://docutils.sf.net/docs/howto/i18n.html>.
9 This package contains modules for language-dependent features of Docutils.
12 __docformat__
= 'reStructuredText'
16 from docutils
.utils
import normalize_language_tag
17 if sys
.version_info
< (2,5):
18 from docutils
._compat
import __import__
22 def get_language(language_code
, reporter
=None):
23 """Return module with language localizations.
25 `language_code` is a "BCP 47" language tag.
26 If there is no matching module, warn and fall back to English.
28 # TODO: use a dummy module returning emtpy strings?, configurable?
29 for tag
in normalize_language_tag(language_code
):
31 return _languages
[tag
]
33 module
= __import__(tag
, globals(), locals(), level
=1)
36 _languages
[tag
] = module
38 if reporter
is not None:
40 'language "%s" not supported: ' % language_code
+
41 'Docutils-generated text will be in English.')
42 module
= __import__('en', globals(), locals(), level
=1)
43 _languages
[tag
] = module
# warn only one time!