comparison i18n/check-translation.py @ 26837:33894facc180 stable

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".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sun, 01 Nov 2015 08:38:56 +0900
parents ad4d6c7aea6a
children 47dd34f2e727
comparison
equal deleted inserted replaced
26836:88c4e97b9669 26837:33894facc180
74 pes = [p for p in pofile if p.msgid == 'DEPRECATED'] 74 pes = [p for p in pofile if p.msgid == 'DEPRECATED']
75 if len(pes): 75 if len(pes):
76 global deprecatedpe 76 global deprecatedpe
77 deprecatedpe = pes[0] 77 deprecatedpe = pes[0]
78 78
79 @fatalchecker('(DEPRECATED)') 79 @fatalchecker(r'\(DEPRECATED\)')
80 def deprecated(pe): 80 def deprecated(pe):
81 """Check for DEPRECATED 81 """Check for DEPRECATED
82 >>> ped = polib.POEntry( 82 >>> ped = polib.POEntry(
83 ... msgid = 'DEPRECATED', 83 ... msgid = 'DEPRECATED',
84 ... msgstr= 'DETACERPED') 84 ... msgstr= 'DETACERPED')
100 ... msgstr= 'something') 100 ... msgstr= 'something')
101 >>> match(deprecated, pe) 101 >>> match(deprecated, pe)
102 True 102 True
103 >>> for e in deprecated(pe): print e 103 >>> for e in deprecated(pe): print e
104 msgstr inconsistently translated (DEPRECATED) 104 msgstr inconsistently translated (DEPRECATED)
105 >>> pe = polib.POEntry(
106 ... msgid = 'Something (DEPRECATED, foo bar)',
107 ... msgstr= 'something (DETACERPED, foo bar)')
108 >>> match(deprecated, pe)
105 """ 109 """
106 if not ('(DEPRECATED)' in pe.msgstr or 110 if not ('(DEPRECATED)' in pe.msgstr or
107 (deprecatedpe and deprecatedpe.msgstr and 111 (deprecatedpe and deprecatedpe.msgstr and
108 deprecatedpe.msgstr in pe.msgstr)): 112 deprecatedpe.msgstr in pe.msgstr)):
109 yield "msgstr inconsistently translated (DEPRECATED)" 113 yield "msgstr inconsistently translated (DEPRECATED)"