Skip to content

Instantly share code, notes, and snippets.

@kgn
Created December 20, 2012 19:34
Show Gist options
  • Save kgn/4347970 to your computer and use it in GitHub Desktop.
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.
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