34 from PyQt5.QtCore import QLocale, QLibraryInfo, QTranslator, QCoreApplication
38 language_path = os.path.dirname(os.path.abspath(__file__))
41 app = QCoreApplication(sys.argv)
44 POT_source = open(os.path.join(language_path,
'OpenShot.pot')).read()
45 all_strings = re.findall(
'^msgid \"(.*)\"', POT_source, re.MULTILINE)
47 print(
"Testing {} strings in all translation files...\n".format(len(all_strings)))
50 for filename
in fnmatch.filter(os.listdir(language_path),
'OpenShot.*.qm'):
51 lang_code = filename[:-3]
53 translator = QTranslator(app)
54 app.installTranslator(translator)
57 success = translator.load(lang_code, language_path)
58 print(
'%s\t%s' % (success, lang_code))
61 for source_string
in all_strings:
62 if "%s" in source_string
or "%s(" in source_string
or "%d" in source_string:
63 translated_string = app.translate(
"", source_string)
64 if source_string.count(
'%') != translated_string.count(
'%'):
65 print(
' Invalid string replacement found: %s (source: %s)' % (translated_string, source_string))
68 app.removeTranslator(translator)