Fix several bits of bad i18n markup and add start of checking script.
[dcpomatic.git] / hacks / check_i18n
1 #!/usr/bin/python3
2
3 import os
4
5 for (dirpath, dirs, files) in os.walk('.'):
6     for filename in files:
7         if filename.endswith('.po'):
8             with open(os.path.join(dirpath, filename), 'r') as f:
9                 for l in f.readlines():
10                     # Pango markup with corrupted quotation marks
11                     if l.find('span') != -1 and (l.find('«') != -1 or l.find('“') != -1):
12                         print(os.path.join(dirpath, filename))
13                         print(l)
14                     # Badly-spaced placeholders
15                     if not l.find('%%') and (l.find('% 1') != -1 or l.find('% 2') != -1 or l.find('% s') != -1 or l.find('% d') != -1 or l.find('% f') != -1):
16                         print(os.path.join(dirpath, filename))
17                         print(l)