Skip to content

Instantly share code, notes, and snippets.

@javipacheco
Created June 14, 2019 11:19
Show Gist options
  • Save javipacheco/279ac41970b1a4d1884fdfb490d9e1f6 to your computer and use it in GitHub Desktop.
Save javipacheco/279ac41970b1a4d1884fdfb490d9e1f6 to your computer and use it in GitHub Desktop.
Generating translating files
import json
import codecs
locales = ["es", "en", "pt", "de", "it", "hi"]
input_file = file("translations.json", "r")
data = json.loads(input_file.read().decode("utf-8-sig"))
for locale in locales:
loc = data['translations'][locale]
output_file = codecs.open('i18n_' + locale + '.json', "w", encoding="utf-8")
json.dump(loc, output_file, indent=4, sort_keys=True, ensure_ascii=False)
print(locale + " created")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment