Created
December 20, 2012 19:34
-
-
Save kgn/4347970 to your computer and use it in GitHub Desktop.
Copy the strings files downloaded from icanlocalize.com back into a Xcode project.
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 os, sys | |
import shutil, fnmatch | |
root = os.path.dirname(os.path.realpath(__file__)) | |
locations = { | |
'Localizable': os.path.join(root, 'Localization'), | |
'Root': os.path.join(root, 'Settings.bundle'), | |
} | |
languages = { | |
'Chinese (Simplified)': 'zh-Hans', | |
'Chinese (Traditional)': 'zh-Hant', | |
'Danish': 'da', | |
'Dutch': 'nl', | |
'French': 'fr', | |
'German': 'de', | |
'Italian': 'it', | |
'Japanese': 'ja', | |
'Russian': 'ru', | |
'Spanish': 'es', | |
} | |
stringsFiles = (os.path.join(r, f) for r, d, fs in os.walk(sys.argv[1]) for f in fnmatch.filter(fs, '*.strings')) | |
for stringsFile in stringsFiles: | |
stringsFileName, ext = os.path.splitext(os.path.basename(stringsFile)) | |
parts = stringsFileName.split('_') | |
if len(parts) != 2: continue | |
language, location = parts | |
destination = os.path.join(locations[location], languages[language]+'.lproj', location+'.strings') | |
shutil.copy2(stringsFile, destination) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment