From: Guenter M. <mi...@us...> - 2017-05-21 10:23:01
|
Dear Dave, On 2017-05-19, Dave Kuhlman wrote: > I did the following: > 1. Merged your changes (patch file below) into my local repository. > 2. Did a bit of testing. I had an exception when a document > contained an admonition. I fixed that. > 3. Committed these changes to the central repository. > Thank you for your help with this. > Let me know if/when there is something more I can do. I have one more patch that makes the code failsafe for Python implementations missing the locale module (e.g. Jython). If you could add a short summary of changed to the HISTORY.txt file, we should be ready for release. Thanks, Günter Index: __init__.py =================================================================== --- __init__.py (Revision 8070) +++ __init__.py (Arbeitskopie) @@ -24,7 +24,10 @@ import copy import urllib2 import docutils -import locale +try: + import locale # module missing in Jython +except ImportError: + pass from docutils import frontend, nodes, utils, writers, languages from docutils.readers import standalone from docutils.transforms import references @@ -589,7 +592,10 @@ elif len(subtag) == 1: break # 1-letter tag is never before valid region tag if region_code is None: - rcode = locale.normalize(language_code) + try: + rcode = locale.normalize(language_code) + except NameError: + rcode = language_code rcode = rcode.split('_') if len(rcode) > 1: rcode = rcode[1].split('.') @@ -596,11 +602,10 @@ region_code = rcode[0] if region_code is None: self.document.reporter.warning( - 'invalid language-region. ' - 'Could not find region with locale.normalize(). ' - 'If language is supplied, then you must specify ' - 'both language and region (ll-RR). Examples: ' - 'es-MX (Spanish, Mexico), en-AU (English, Australia).') + 'invalid language-region.\n' + ' Could not find region with locale.normalize().\n' + ' Please specify both language and region (ll-RR).\n' + ' Examples: es-MX (Spanish, Mexico), en-AU (English, Australia).') # Update the style ElementTree with the language and region. # Note that we keep a reference to the modified node because # it is possible that ElementTree will throw away the Python |