Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language string comparison implementation #932

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions assets/i18n/compare_language_strings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys, json

def compare_language_strings(from_language_file, to_language_file, differences_file):
with open(from_language_file, "r", encoding='utf-8') as r: # Opening file contains an updated strings, for example en_US.json
from_language_data = json.load(r)
with open(to_language_file, "r", encoding='utf-8') as r: # Language JSON file you translating
to_language_data = json.load(r)
key_difference = {} # Difference between new keys and keys you translated in your language
for key, value in from_language_data.items():
if key not in to_language_data:
key_difference[key] = value
with open(differences_file, "w", encoding='utf-8') as w: # File to save differences between keys in updated language file, and language file you translating
json.dump(key_difference, w, ensure_ascii=False, indent=2)
print('Language comparison complete.')

if len(sys.argv) != 4:
print(sys.argv[0], ' from_language_file to_language_file differences_file')
sys.exit()
compare_language_strings(sys.argv[1], sys.argv[2], sys.argv[3])