Commit | Line | Data |
---|---|---|
3719602c PC |
1 | #!/usr/bin/env python3 |
2 | ||
3 | import core_opt_translation as t | |
4 | ||
5 | ||
6 | if __name__ == '__main__': | |
7 | try: | |
8 | if t.os.path.isfile(t.sys.argv[1]): | |
9 | _temp = t.os.path.dirname(t.sys.argv[1]) | |
10 | else: | |
11 | _temp = t.sys.argv[1] | |
12 | while _temp.endswith('/') or _temp.endswith('\\'): | |
13 | _temp = _temp[:-1] | |
14 | TARGET_DIR_PATH = _temp | |
15 | except IndexError: | |
16 | TARGET_DIR_PATH = t.os.path.dirname(t.os.path.dirname(t.os.path.realpath(__file__))) | |
17 | print("No path provided, assuming parent directory:\n" + TARGET_DIR_PATH) | |
18 | ||
19 | DIR_PATH = t.os.path.dirname(t.os.path.realpath(__file__)) | |
20 | H_FILE_PATH = t.os.path.join(TARGET_DIR_PATH, 'libretro_core_options.h') | |
21 | INTL_FILE_PATH = t.os.path.join(TARGET_DIR_PATH, 'libretro_core_options_intl.h') | |
22 | ||
23 | _core_name = 'core_options' | |
24 | _core_name = t.clean_file_name(_core_name) | |
25 | ||
26 | print('Getting texts from libretro_core_options.h') | |
27 | with open(H_FILE_PATH, 'r+', encoding='utf-8') as _h_file: | |
28 | _main_text = _h_file.read() | |
29 | _hash_n_str = t.get_texts(_main_text) | |
30 | _files = t.create_msg_hash(DIR_PATH, _core_name, _hash_n_str) | |
31 | ||
32 | print('Converting translations *.json to *.h:') | |
33 | for _folder in t.os.listdir(DIR_PATH): | |
34 | if t.os.path.isdir(t.os.path.join(DIR_PATH, _folder))\ | |
35 | and _folder.startswith('_')\ | |
36 | and _folder != '__pycache__': | |
37 | print(_folder) | |
38 | t.json2h(DIR_PATH, t.os.path.join(DIR_PATH, _folder), _core_name) | |
39 | ||
40 | print('Constructing libretro_core_options_intl.h') | |
41 | t.create_intl_file(INTL_FILE_PATH, DIR_PATH, _main_text, _core_name, _files['_us']) | |
42 | ||
43 | print('\nAll done!') |