From 64ebbcfbaebf8b534f6a29e11c486a5dcd94aedb Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 12 Apr 2014 06:16:32 -0700 Subject: [PATCH] mods to export getString --- xwords4/android/scripts/mk_xml.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/xwords4/android/scripts/mk_xml.py b/xwords4/android/scripts/mk_xml.py index aa76c65ad..e2463bfcd 100755 --- a/xwords4/android/scripts/mk_xml.py +++ b/xwords4/android/scripts/mk_xml.py @@ -135,6 +135,15 @@ public class %s { """ fil.write( lines ) +def getStrings(): + pairs = {} + for path in glob.iglob( "res/values/strings.xml" ): + for action, elem in etree.iterparse(path): + if "end" == action and 'string' == elem.tag and elem.text: + text = checkText( elem.text ) + pairs[elem.get('name')] = text + return pairs + def main(): outfile = '' outfileDbg = '' @@ -145,11 +154,7 @@ def main(): elif option == '-t': target = value # Gather all localizable strings - for path in glob.iglob( "res/values/strings.xml" ): - for action, elem in etree.iterparse(path): - if "end" == action and 'string' == elem.tag and elem.text: - text = checkText( elem.text ) - g_pairs[elem.get('name')] = text + pairs = getStrings() # for subdir, dirs, files in os.walk('res_src'): # for file in files: @@ -157,7 +162,8 @@ def main(): # dest = src.replace( 'res_src', 'res', 1 ) # xform( src, dest ) - if outfile: printStrings( g_pairs, outfile, target ) + if outfile: printStrings( pairs, outfile, target ) - -main() +############################################################################## +if __name__ == '__main__': + main()