Created
July 13, 2017 16:40
-
-
Save corcoran/9f620d4a190f0889976cbf7a0160ec79 to your computer and use it in GitHub Desktop.
CrowdIn translations Android helper
This file contains hidden or 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
#!/usr/bin/env python | |
import os | |
import shutil | |
import zipfile | |
# Fully translated only | |
translation_mapping = { | |
'cs': 'cs', | |
'de': 'de', | |
'fr': 'fr', | |
'hi': 'hi-rIN', | |
'hu': 'hu', | |
'it': 'it', | |
'ja': 'ja', | |
'nl': 'nl', | |
'pl': 'pl', | |
'pt-BR': 'pt', | |
'ro': 'ro', | |
'ru': 'ru', | |
'sk': 'sk', | |
'tr': 'tr', | |
'uk': 'uk', | |
'zh-CN': 'zh-rCN' | |
} | |
zip_file = "/home/jeff/Downloads/xda-feed.zip" | |
tmp_dir = "/tmp/feed_translations" | |
dst_dir = "/home/jeff/Android/Feed/app/src/main/res" | |
str_file = "strings.xml" | |
if __name__ == "__main__": | |
zip_ref = zipfile.ZipFile(zip_file, 'r') | |
zip_ref.extractall(tmp_dir) | |
zip_ref.close() | |
for l in sorted(translation_mapping.keys()): | |
dest_path = '%s/values-%s' % (dst_dir, translation_mapping[l]) | |
if not os.path.exists(dest_path): | |
os.mkdir(dest_path) | |
shutil.copy('%s/%s/%s' % (tmp_dir, l, str_file), '%s/%s' % (dest_path, | |
str_file)) | |
print("Copied new values-%s/%s" % (translation_mapping[l], str_file)) | |
shutil.rmtree(tmp_dir, True) | |
os.unlink(zip_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment