comparison i18n/check-translation.py @ 26852:3fb36dec1727 stable

i18n: do not abuse msgstr of "DEPRECATED" to check for bad translation Because 44cc9f63a2f1 requires the msgstr of "(DEPRECATED)", old *.po files must be blamed. Using "DEPRECATED" would just hide the error. For example, "LANG=da_DK.UTF-8 hg help serve" fails to hide deprecated options right now, but check-translation.py couldn't detect it because da.po has outdated translation of "DEPRECATED".
author Yuya Nishihara <yuya@tcha.org>
date Tue, 03 Nov 2015 22:39:26 +0900
parents 47dd34f2e727
children 29238dbf718e
comparison
equal deleted inserted replaced
26840:58b7f3e93bba 26852:3fb36dec1727
69 yield "msgstr has invalid '&' followed by none" 69 yield "msgstr has invalid '&' followed by none"
70 70
71 deprecatedpe = None 71 deprecatedpe = None
72 @scanner() 72 @scanner()
73 def deprecatedsetup(pofile): 73 def deprecatedsetup(pofile):
74 pes = [p for p in pofile 74 pes = [p for p in pofile if p.msgid == '(DEPRECATED)' and p.msgstr]
75 if ((p.msgid == 'DEPRECATED' or p.msgid == '(DEPRECATED)') and
76 p.msgstr)]
77 if len(pes): 75 if len(pes):
78 global deprecatedpe 76 global deprecatedpe
79 deprecatedpe = pes[0] 77 deprecatedpe = pes[0]
80 78
81 @fatalchecker(r'\(DEPRECATED\)') 79 @fatalchecker(r'\(DEPRECATED\)')
82 def deprecated(pe): 80 def deprecated(pe):
83 """Check for DEPRECATED 81 """Check for DEPRECATED
84 >>> ped = polib.POEntry( 82 >>> ped = polib.POEntry(
85 ... msgid = 'DEPRECATED', 83 ... msgid = '(DEPRECATED)',
86 ... msgstr= 'DETACERPED') 84 ... msgstr= '(DETACERPED)')
87 >>> deprecatedsetup([ped]) 85 >>> deprecatedsetup([ped])
88 >>> pe = polib.POEntry( 86 >>> pe = polib.POEntry(
89 ... msgid = 'Something (DEPRECATED)', 87 ... msgid = 'Something (DEPRECATED)',
90 ... msgstr= 'something (DEPRECATED)') 88 ... msgstr= 'something (DEPRECATED)')
91 >>> match(deprecated, pe) 89 >>> match(deprecated, pe)