[PATCH 1 of 4] i18n: calculate correct line number in source of messages to be translated

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Feb 11 14:18:25 UTC 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1455200134 -32400
#      Thu Feb 11 23:15:34 2016 +0900
# Node ID 55f023455fd8450ffe8807058c2cb75ae1a87281
# Parent  8515b813976bfab2abadfc95011807bd8c7a2816
i18n: calculate correct line number in source of messages to be translated

Before this patch, line number in source of the message to be
translated is wrong in hg.pot, if corresponded message is placed after
".. DIRECTIVE::", because number of lines related to such directive
isn't added to variable "delta", which holds number of untranslated
lines in given text.

This patch always adds "2" to "delta", because text block is split
into translation units by "\n\n".

diff --git a/i18n/posplit b/i18n/posplit
--- a/i18n/posplit
+++ b/i18n/posplit
@@ -57,11 +57,13 @@ if __name__ == "__main__":
                 if mdirective:
                     if not msgid[mdirective.end():].rstrip():
                         # only directive, nothing to translate here
+                        delta += 2
                         continue
                     directive = mdirective.group(1)
                     if directive in ('container', 'include'):
                         if msgid.rstrip('\n').count('\n') == 0:
                             # only rst syntax, nothing to translate
+                            delta += 2
                             continue
                         else:
                             # lines following directly, unexpected


More information about the Mercurial-devel mailing list