mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
move French strings into res_src/, and add script to filter/copy all
strings.xml files from there to res/, effectively including them in the app the way the Android SDK intends. This will allow me to turn off the downloadable localization stuff which is tripping over having more than English built in. ToDo: incorporate the copy into the build.
This commit is contained in:
parent
2c1ee29c2f
commit
ac811f1690
8 changed files with 3479 additions and 2263 deletions
File diff suppressed because it is too large
Load diff
1
xwords4/android/XWords4/res/values-ca/.gitignore
vendored
Normal file
1
xwords4/android/XWords4/res/values-ca/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/strings.xml
|
1
xwords4/android/XWords4/res/values-cs/.gitignore
vendored
Normal file
1
xwords4/android/XWords4/res/values-cs/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/strings.xml
|
1
xwords4/android/XWords4/res/values-fr/.gitignore
vendored
Normal file
1
xwords4/android/XWords4/res/values-fr/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/strings.xml
|
1
xwords4/android/XWords4/res/values-pt/.gitignore
vendored
Normal file
1
xwords4/android/XWords4/res/values-pt/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/strings.xml
|
1
xwords4/android/XWords4/res/values-sk/.gitignore
vendored
Normal file
1
xwords4/android/XWords4/res/values-sk/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/strings.xml
|
3398
xwords4/android/XWords4/res_src/values-fr/strings.xml
Normal file
3398
xwords4/android/XWords4/res_src/values-fr/strings.xml
Normal file
File diff suppressed because it is too large
Load diff
76
xwords4/android/scripts/copy-strings.py
Executable file
76
xwords4/android/scripts/copy-strings.py
Executable file
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Go through all the res_src strings.xml files, and copy them over
|
||||
# into the world where they'll get used in a build. This is meant to
|
||||
# allow them to be built-in as an alternative to the
|
||||
# locutils/downloadable system.
|
||||
|
||||
import re, sys, os, getopt
|
||||
from lxml import etree
|
||||
|
||||
def checkAndCopy( engNames, src, dest ):
|
||||
parser = etree.XMLParser(remove_blank_text=True, encoding="utf-8")
|
||||
doc = etree.parse(src, parser)
|
||||
for elem in doc.getroot().iter():
|
||||
if 'resources' == elem.tag:
|
||||
pass
|
||||
elif 'item' == elem.tag:
|
||||
pass
|
||||
elif 'string' == elem.tag:
|
||||
name = elem.get('name')
|
||||
if not name in engNames or not 'string' == engNames[name]:
|
||||
print 'removing', name
|
||||
elem.getparent().remove( elem )
|
||||
elif 'plurals' == elem.tag:
|
||||
name = elem.get('name')
|
||||
if not name in engNames or not 'plurals' == engNames[name]:
|
||||
print 'removing', name
|
||||
elem.getparent().remove( elem )
|
||||
elif not isinstance( elem.tag, basestring ): # comment
|
||||
elem.getparent().remove(elem)
|
||||
else:
|
||||
print 'unexpected elem:', elem.tag
|
||||
sys.exit(1)
|
||||
|
||||
if True:
|
||||
dir = os.path.dirname( dest )
|
||||
try: os.makedirs( dir )
|
||||
except: pass
|
||||
out = open( dest, "w" )
|
||||
out.write( etree.tostring( doc, pretty_print=True, encoding="utf-8", xml_declaration=True ) )
|
||||
|
||||
def main():
|
||||
# add these via params later
|
||||
excepts = ['values-ca_PS', 'values-ba_CK']
|
||||
|
||||
# summarize the english file
|
||||
wd = os.path.dirname(sys.argv[0])
|
||||
path = wd + '/../XWords4/res/values/strings.xml'
|
||||
engNames = {}
|
||||
|
||||
engFormats = {}
|
||||
parser = etree.XMLParser(remove_blank_text=True, encoding="utf-8")
|
||||
doc = etree.parse(path, parser)
|
||||
pat = re.compile( '(%\d\$[sd])', re.DOTALL | re.MULTILINE )
|
||||
for typ in ['string', 'plurals']:
|
||||
for elem in doc.findall(typ):
|
||||
name = elem.get('name')
|
||||
engNames[name] = typ
|
||||
|
||||
# print engNames
|
||||
|
||||
# iterate over src files
|
||||
for subdir, dirs, files in os.walk('res_src'):
|
||||
for file in [file for file in files if file == "strings.xml"]:
|
||||
path = "%s/%s" % (subdir, file)
|
||||
for excpt in excepts:
|
||||
if excpt in path :
|
||||
path = None
|
||||
break
|
||||
if path:
|
||||
dest = path.replace( 'res_src', 'res', 1 )
|
||||
checkAndCopy( engNames, path, dest )
|
||||
|
||||
##############################################################################
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in a new issue