[PATCH 1 of 2 STABLE] i18n: fix regexp pattern to detect translation for DEPRECATED
Yuya Nishihara
yuya at tcha.org
Sun Nov 1 13:53:07 UTC 2015
On Sun, 01 Nov 2015 08:57:32 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1446334736 -32400
> # Sun Nov 01 08:38:56 2015 +0900
> # Branch stable
> # Node ID 6d0e49b14bc092b89b81a15cf31e0ad1f63eb639
> # Parent 6474b64045fb83733d6f7b774bbc8b2869bd1fed
> i18n: fix regexp pattern to detect translation for DEPRECATED
>
> Since 44cc9f63a2f1, deprecated commands, options and so on are
> detected by "(DEPRECATED)" instead of "DEPRECATED".
>
> Therefore, 'deprecated' checker in i18n/check-translation.py should
> check translation, of which msgid contains "(DEPRECATED)" instead of
> "DEPRECATED".
>
> At glance, it seems to do so, but it actually doesn't, because Python
> regexp treats "()" as grouping of patterns and "(DEPRECATED)" matches
> only against "DEPRECATED".
>
> diff --git a/i18n/check-translation.py b/i18n/check-translation.py
> --- a/i18n/check-translation.py
> +++ b/i18n/check-translation.py
> @@ -76,7 +76,7 @@ def deprecatedsetup(pofile):
> global deprecatedpe
> deprecatedpe = pes[0]
>
> - at fatalchecker('(DEPRECATED)')
> + at fatalchecker(r'\(DEPRECATED\)')
> def deprecated(pe):
> """Check for DEPRECATED
> >>> ped = polib.POEntry(
> @@ -102,6 +102,10 @@ def deprecated(pe):
> True
> >>> for e in deprecated(pe): print e
> msgstr inconsistently translated (DEPRECATED)
> + >>> pe = polib.POEntry(
> + ... msgid = 'Something (DEPRECATED, foo bar)',
> + ... msgstr= 'something (DETACERPED, foo bar)')
> + >>> match(deprecated, pe)
This looks good to me.
More information about the Mercurial-devel
mailing list