You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1022 B

#!/usr/bin/env python
This script can be used to grep the source to tree to see which localized strings are in use.
author: corbett
usage: ./ Localizable.strings source_dir
eg: ./ ../Signal/translations/en.lproj/Localizable.strings ../Signal/src
import sys
import os
import re
def file_match(fname, pat):
f = open(fname, "rt")
except IOError:
for i, line in enumerate(f):
return True
return False
def rgrep_match(dir_name, s_pat):
pat = re.compile(s_pat)
for dirpath, dirnames, filenames in os.walk(dir_name):
for fname in filenames:
fullname = os.path.join(dirpath, fname)
match=file_match(fullname, pat)
if match:
return match
return False
if __name__ == '__main__':
strings_file = sys.argv[1]
src_dir_name = sys.argv[2]
for item in open(strings_file).readlines():
grep_for = item.strip().split(' = ')[0].replace('"','')
if rgrep_match(src_dir_name, grep_for):
print item.strip()