mirror of
https://github.com/flameshikari/outline-ru.git
synced 2026-06-13 04:05:10 +03:00
update diff.py
This commit is contained in:
+15
-7
@@ -19,6 +19,8 @@ translated_lines = {}
|
|||||||
untranslated_lines = {}
|
untranslated_lines = {}
|
||||||
exception_lines = {}
|
exception_lines = {}
|
||||||
|
|
||||||
|
placeholder = '[NOT TRANSLATED]'
|
||||||
|
|
||||||
with open(en_json_path) as target:
|
with open(en_json_path) as target:
|
||||||
en_json = json.load(target)
|
en_json = json.load(target)
|
||||||
|
|
||||||
@@ -26,20 +28,26 @@ with open(ru_json_path) as target:
|
|||||||
ru_json = json.load(target)
|
ru_json = json.load(target)
|
||||||
|
|
||||||
for key, value in en_json.items():
|
for key, value in en_json.items():
|
||||||
if key in ru_json.keys():
|
|
||||||
|
# skip x_plural strings
|
||||||
|
if key.endswith('_plural'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
# keep translated strings
|
||||||
|
elif key in ru_json.keys():
|
||||||
translated_lines[key] = ru_json[key]
|
translated_lines[key] = ru_json[key]
|
||||||
|
|
||||||
|
# process plurals
|
||||||
elif key in en_json.keys() and f'{key}_plural' in en_json.keys():
|
elif key in en_json.keys() and f'{key}_plural' in en_json.keys():
|
||||||
for i in range(0, 3):
|
for i in range(0, 3):
|
||||||
plural = f'{key}_{i}'
|
plural = f'{key}_{i}'
|
||||||
if plural in ru_json.keys():
|
if plural in ru_json.keys():
|
||||||
translated_lines[plural] = ru_json[plural]
|
translated_lines[plural] = ru_json[plural]
|
||||||
elif key.endswith('_plural'):
|
else:
|
||||||
if key.replace('_plural', '_0') in ru_json.keys():
|
untranslated_lines[plural] = placeholder
|
||||||
pass
|
|
||||||
else:
|
|
||||||
untranslated_lines[key] = en_json[key]
|
|
||||||
else:
|
else:
|
||||||
untranslated_lines[key] = en_json[key]
|
untranslated_lines[key] = placeholder
|
||||||
|
|
||||||
for key, value in ru_json.items():
|
for key, value in ru_json.items():
|
||||||
if key == value:
|
if key == value:
|
||||||
|
|||||||
Reference in New Issue
Block a user