|
41 | 41 | app = QCoreApplication(sys.argv)
|
42 | 42 |
|
43 | 43 | # Load POT template (all English strings)
|
44 |
| -POT_source = open(os.path.join(language_path, 'OpenShot', 'OpenShot.pot')).read() |
45 |
| -all_strings = re.findall('^msgid \"(.*)\"', POT_source, re.MULTILINE) |
46 |
| - |
47 |
| -print("Scanning {} strings in all translation files...".format(len(all_strings))) |
48 |
| - |
49 |
| -# Loop through folders/languages |
50 |
| -for filename in fnmatch.filter(os.listdir(language_path), 'OpenShot_*.qm'): |
51 |
| - lang_code = filename[:-3] |
52 |
| - # Install language |
53 |
| - translator = QTranslator(app) |
54 |
| - |
55 |
| - # Load translation |
56 |
| - if translator.load(lang_code, language_path): |
57 |
| - app.installTranslator(translator) |
58 |
| - |
59 |
| - print("\n=================================================") |
60 |
| - print("Showing translations for {}".format(filename)) |
61 |
| - print("=================================================") |
62 |
| - # Loop through all test strings |
63 |
| - for source_string in all_strings: |
64 |
| - translated_string = app.translate("", source_string) |
65 |
| - if source_string != translated_string: |
66 |
| - print(' {} => {}'.format(source_string,translated_string)) |
67 |
| - # Remove translator |
68 |
| - app.removeTranslator(translator) |
| 44 | +all_templates = ['OpenShot.pot', 'OpenShot_transitions.pot', 'OpenShot_blender.pot'] |
| 45 | +for template_name in all_templates: |
| 46 | + POT_source = open(os.path.join(language_path, 'OpenShot', template_name)).read() |
| 47 | + all_strings = re.findall('^msgid \"(.*)\"', POT_source, re.MULTILINE) |
| 48 | + |
| 49 | + print("Scanning {} strings in all translation files...".format(len(all_strings))) |
| 50 | + |
| 51 | + # Loop through folders/languages |
| 52 | + for filename in fnmatch.filter(os.listdir(language_path), 'OpenShot*.qm'): |
| 53 | + lang_code = filename[:-3] |
| 54 | + # Install language |
| 55 | + translator = QTranslator(app) |
| 56 | + |
| 57 | + # Load translation |
| 58 | + if translator.load(lang_code, language_path): |
| 59 | + app.installTranslator(translator) |
| 60 | + |
| 61 | + print("\n=================================================") |
| 62 | + print("Showing translations for {}".format(filename)) |
| 63 | + print("=================================================") |
| 64 | + # Loop through all test strings |
| 65 | + for source_string in all_strings: |
| 66 | + translated_string = app.translate("", source_string) |
| 67 | + if source_string != translated_string: |
| 68 | + print(' {} => {}'.format(source_string,translated_string)) |
| 69 | + |
| 70 | + if "%s" in source_string or "%s(" in source_string or "%d" in source_string: |
| 71 | + if source_string.count('%') != translated_string.count('%'): |
| 72 | + raise(Exception('Invalid string replacement found: "%s" vs "%s" [%s]' % |
| 73 | + (translated_string, source_string, lang_code))) |
| 74 | + |
| 75 | + # Remove translator |
| 76 | + app.removeTranslator(translator) |
0 commit comments