Created
June 14, 2019 11:19
-
-
Save javipacheco/279ac41970b1a4d1884fdfb490d9e1f6 to your computer and use it in GitHub Desktop.
Generating translating files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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