utils: checking for bitcoin addresses in translations
Checking for and removing any bitcoin addresses in translations
This commit is contained in:
parent
e24bf1ce18
commit
85f0135eae
1 changed files with 9 additions and 1 deletions
|
@ -30,6 +30,8 @@ SOURCE_LANG = 'bitcoin_en.ts'
|
|||
LOCALE_DIR = 'src/qt/locale'
|
||||
# Minimum number of messages for translation to be considered at all
|
||||
MIN_NUM_MESSAGES = 10
|
||||
# Regexp to check for Bitcoin addresses
|
||||
ADDRESS_REGEXP = re.compile('([13]|bc1)[a-zA-Z0-9]{30,}')
|
||||
|
||||
def check_at_repository_root():
|
||||
if not os.path.exists('.git'):
|
||||
|
@ -122,6 +124,12 @@ def escape_cdata(text):
|
|||
text = text.replace('"', '"')
|
||||
return text
|
||||
|
||||
def contains_bitcoin_addr(text, errors):
|
||||
if text != None and ADDRESS_REGEXP.search(text) != None:
|
||||
errors.append('Translation "%s" contains a bitcoin address. This will be removed.' % (text))
|
||||
return True
|
||||
return False
|
||||
|
||||
def postprocess_translations(reduce_diff_hacks=False):
|
||||
print('Checking and postprocessing...')
|
||||
|
||||
|
@ -160,7 +168,7 @@ def postprocess_translations(reduce_diff_hacks=False):
|
|||
if translation is None:
|
||||
continue
|
||||
errors = []
|
||||
valid = check_format_specifiers(source, translation, errors, numerus)
|
||||
valid = check_format_specifiers(source, translation, errors, numerus) and not contains_bitcoin_addr(translation, errors)
|
||||
|
||||
for error in errors:
|
||||
print('%s: %s' % (filename, error))
|
||||
|
|
Loading…
Reference in a new issue