12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import copy
- from pathlib import Path
- import yaml
- I18N_PATH = Path(__file__).resolve().parent.parent.joinpath('wowchemy').joinpath('i18n')
- MASTER_PACK = I18N_PATH.joinpath('en.yaml')
- with open(MASTER_PACK) as f:
- master_map = yaml.safe_load(f)
-
-
- cnt = 0
- for filename in Path(I18N_PATH).glob("*.yaml"):
- if filename.stem != 'en':
- i18n_file = I18N_PATH.joinpath(filename)
- print(f"Processing {i18n_file} ...")
-
- with open(i18n_file) as f:
- child_map = yaml.safe_load(f)
-
- tmp_map = copy.deepcopy(master_map)
- master_index = 0
- for master_item in master_map:
- translation = next((item['translation'] for item in child_map if item['id'] == master_item['id']),
- master_item['translation'])
- tmp_map[master_index]['translation'] = translation
- master_index += 1
-
- with open(i18n_file, 'w') as f:
-
-
-
- yaml.dump(tmp_map, f, allow_unicode=True, width=float("inf"))
- cnt += 1
- print(f"{cnt} child language packs successfully synchronized!")
|