mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
generate menu resources from the old files, adding the 'loc:' key for those title strings listed in strings.xml
This commit is contained in:
parent
96194671e2
commit
aad4872f68
3 changed files with 44 additions and 0 deletions
|
@ -102,6 +102,11 @@
|
||||||
failonerror="true" output="/dev/null"
|
failonerror="true" output="/dev/null"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<exec dir="." executable="../scripts/mk_xml.py"
|
||||||
|
failonerror="true" output="/dev/null"
|
||||||
|
>
|
||||||
|
</exec>
|
||||||
|
|
||||||
<exec dir="." executable="../scripts/gen_gcmid.sh"
|
<exec dir="." executable="../scripts/gen_gcmid.sh"
|
||||||
output="src/org/eehouse/android/xw4bt/GCMConsts.java"
|
output="src/org/eehouse/android/xw4bt/GCMConsts.java"
|
||||||
failonerror="true" logError="true"
|
failonerror="true" logError="true"
|
||||||
|
|
6
xwords4/android/XWords4/res/menu/.gitignore
vendored
Normal file
6
xwords4/android/XWords4/res/menu/.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/board_menu.xml
|
||||||
|
/chat_menu.xml
|
||||||
|
/dicts_menu.xml
|
||||||
|
/games_list_menu.xml
|
||||||
|
/loc_menu.xml
|
||||||
|
/studylist.xml
|
33
xwords4/android/scripts/mk_xml.py
Executable file
33
xwords4/android/scripts/mk_xml.py
Executable file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import glob, sys, re, os
|
||||||
|
from lxml import etree
|
||||||
|
|
||||||
|
pairs = {}
|
||||||
|
|
||||||
|
STR_REF = re.compile('@string/(.*)$')
|
||||||
|
|
||||||
|
def xform(src, dest):
|
||||||
|
doc = etree.parse(src)
|
||||||
|
for item in doc.findall('item'):
|
||||||
|
title = item.get('{http://schemas.android.com/apk/res/android}title')
|
||||||
|
if title:
|
||||||
|
match = STR_REF.match(title)
|
||||||
|
if match:
|
||||||
|
key = match.group(1)
|
||||||
|
if key in pairs:
|
||||||
|
print key, "loc:" + key
|
||||||
|
item.set('{http://schemas.android.com/apk/res/android}title', "loc:" + key)
|
||||||
|
doc.write( dest, pretty_print=True )
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
pairs[elem.get('name')] = True
|
||||||
|
|
||||||
|
for subdir, dirs, files in os.walk('res_src'):
|
||||||
|
for file in files:
|
||||||
|
src = subdir + '/' + file
|
||||||
|
dest = src.replace( 'res_src', 'res', 1 )
|
||||||
|
xform( src, dest )
|
Loading…
Reference in a new issue