diff options
author | shimizukawa <shimizukawa@gmail.com> | 2012-12-07 16:38:21 +0900 |
---|---|---|
committer | shimizukawa <shimizukawa@gmail.com> | 2012-12-07 16:38:21 +0900 |
commit | 68c8e824d8b0dd5a4efe3de445f431f3389891dd (patch) | |
tree | 8d2a2382f4e445acd7950f74459cc00fde022c96 | |
parent | 407ce391fd453c901eb3fa19f7b0f621b526ea55 (diff) | |
download | sphinx-68c8e824d8b0dd5a4efe3de445f431f3389891dd.tar.gz |
Update warnings for inconsistency reference translations. Thanks @jonwaltman!
-rw-r--r-- | sphinx/environment.py | 11 | ||||
-rw-r--r-- | tests/test_intl.py | 9 |
2 files changed, 11 insertions, 9 deletions
diff --git a/sphinx/environment.py b/sphinx/environment.py index 4a4ffa72..1adc6809 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -234,9 +234,8 @@ class Locale(Transform): old_foot_refs = node.traverse(is_autonumber_footnote_ref) new_foot_refs = patch.traverse(is_autonumber_footnote_ref) if len(old_foot_refs) != len(new_foot_refs): - env.warn_node('The number of reference are inconsistent ' - 'in both the translated form and the ' - 'untranslated form. skip translation.', node) + env.warn_node('inconsistent footnote references in ' + 'translated message', node) for old, new in zip(old_foot_refs, new_foot_refs): new['ids'] = old['ids'] self.document.autofootnote_refs.remove(old) @@ -253,9 +252,8 @@ class Locale(Transform): new_refs = patch.traverse(is_refnamed_ref) applied_refname_map = {} if len(old_refs) != len(new_refs): - env.warn_node('The number of reference are inconsistent ' - 'in both the translated form and the ' - 'untranslated form. skip translation.', node) + env.warn_node('inconsistent references in ' + 'translated message', node) for new in new_refs: if new['refname'] in applied_refname_map: # 2nd appearance of the reference @@ -1813,4 +1811,3 @@ class BuildEnvironment: if 'orphan' in self.metadata[docname]: continue self.warn(docname, 'document isn\'t included in any toctree') - diff --git a/tests/test_intl.py b/tests/test_intl.py index c2c4cb2a..94b21e8d 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -120,8 +120,13 @@ def test_i18n_warn_for_number_of_references_inconsistency(app): assert result == expect warnings = warnfile.getvalue().replace(os.sep, '/') - expected_warning_expr = "i18n/refs_inconsistency.txt:\d+: WARNING: The number of reference are inconsistent in both the translated form and the untranslated form. skip translation." - assert len(re.findall(expected_warning_expr, warnings)) == 3 + warning_fmt = u'.*/i18n/refs_inconsistency.txt:\\d+: ' \ + u'WARNING: inconsistent %s in translated message\n' + expected_warning_expr = ( + warning_fmt % 'footnote references' + + warning_fmt % 'references' + + warning_fmt % 'references') + assert re.search(expected_warning_expr, warnings) @with_app(buildername='html', cleanenv=True, |