Skip to content

Instantly share code, notes, and snippets.

@notz
Created February 14, 2017 17:40
Show Gist options
  • Save notz/0fac9383687f8215b2b3edec1206caa0 to your computer and use it in GitHub Desktop.
Save notz/0fac9383687f8215b2b3edec1206caa0 to your computer and use it in GitHub Desktop.
Merges iOS fallback strings for not translated strings (jenkins build step)
#!/usr/local/bin/python3.5
# -*- coding: utf-8 -*-
from nslocalized import StringTable
import glob
import re
def merge(source, destination):
try:
st = StringTable.read(source)
try:
st.read(destination)
except:
print("unable to load destination file: ", destination)
st.write(destination)
except:
print("unable to load source file: ", source)
for filename in glob.iglob('**/*.strings', recursive=True):
if not re.match('.*\/en\.lproj\/.*', filename):
merge(re.sub(r"\/\w+\.lproj\/", "/en.lproj/", filename), filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment