Mini Shell
#!/opt/cloudlinux/venv/bin/python3 -bb
# coding:utf-8
# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENSE.TXT
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
import json
import os
BASE_DIR = os.path.join(os.path.dirname(__file__), "../")
I18N_SOURCE = BASE_DIR + 'commons/spa-resources/i18n/'
en = json.load(open(I18N_SOURCE + 'en-en.json'))
ru = json.load(open(I18N_SOURCE + 'ru-ru.json'))
def parse(ru, en):
"""
Get value from en-EN.json. if not exist - get key from ru.json
Save data to only_en.json
:param ru: current position in ru.json
:param en: current position in en-EN.json
:return:None
"""
for k, v in ru.items():
if isinstance(v, dict):
parse(v, en[k])
else:
ru[k] = en.get(k, k)
if __name__ == '__main__':
parse(ru, en)
json.dump(ru, open(I18N_SOURCE + 'translate_template.json', 'w'), indent=4)
Zerion Mini Shell 1.0