Skip to content

Instantly share code, notes, and snippets.

@shuuji3
Last active February 17, 2023 09:08
Show Gist options
  • Save shuuji3/2db21723f12989d8a06b6259232c6b74 to your computer and use it in GitHub Desktop.
Save shuuji3/2db21723f12989d8a06b6259232c6b74 to your computer and use it in GitHub Desktop.
Print out the differences of JSON keys to detect the Elk's localization update.
# Print out the differences of JSON keys to detect the Elk's localization update.
import json
def recursive_items(dictionary, prefix=''):
for key, value in dictionary.items():
if type(value) is dict:
yield (f'{prefix}{key}', value)
yield from recursive_items(value, prefix=f'{key}.')
else:
yield (f'{prefix}{key}', value)
def main():
with open('locales/en.json') as en, open('locales/ja-JP.json') as ja:
en = json.load(en)
ja = json.load(ja)
en_keys = {k for k, v in recursive_items(en)}
ja_keys = {k for k, v in recursive_items(ja)}
diff = en_keys ^ ja_keys
print(f'diff: {diff}')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment