1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 19:42:17 +02:00

resources synchronization script + synchronized resources

This commit is contained in:
Nikolay Pultsin 2012-09-18 02:56:00 +04:00
parent 186251ab79
commit 40d76fdd68
24 changed files with 161 additions and 2 deletions

36
scripts/resources/repair.py Executable file
View file

@ -0,0 +1,36 @@
#!/usr/bin/python
import sys
from xml.dom import minidom
def processNodes(base, custom):
customChild = custom.firstChild
for baseChild in base.childNodes:
if baseChild.nodeType != minidom.Node.ELEMENT_NODE:
continue
while customChild is not None and customChild.nodeType != minidom.Node.ELEMENT_NODE:
customChild = customChild.nextSibling
if baseChild.nodeName == 'node':
name = baseChild.getAttribute('name')
if name == '':
continue
if customChild is None or name != customChild.getAttribute('name'):
newNode = custom.ownerDocument.createElement('node')
newNode.setAttribute('name', name);
value = baseChild.getAttribute('value')
if value != '':
newNode.setAttribute('value', value);
newNode.setAttribute('toBeTranslated', 'true');
customChild = custom.insertBefore(newNode, customChild)
processNodes(baseChild, customChild)
customChild = customChild.nextSibling
if len(sys.argv) != 3:
print 'Usage: %s <en.xml> <custom.xml>' % sys.argv[0]
exit(1)
base_model = minidom.parse(sys.argv[1])
custom_model = minidom.parse(sys.argv[2])
processNodes(base_model, custom_model)
print custom_model.toxml('UTF-8')

View file

@ -0,0 +1,23 @@
#!/bin/sh
doRepair() {
./repair.py $1 $2 | xmllint --format - | sed 's/\(toBeTranslated="true"\) \(value=".*"\)\(.*\)$/\2 \1\3/'
}
if [ "$1" == "" ]; then
part=application
else
part=$1
fi
sed "s/&#10;/#XXX;/g" ../../assets/resources/$part/en.xml > en.tra
for file in ../../assets/resources/$part/*.xml; do
shortname=`basename $file .xml`
if [ $shortname != en ]; then
sed "s/&#10;/#XXX;/g" $file > $shortname.tra
doRepair en.tra $shortname.tra | sed "s/#XXX;/\&#10;/g" > $file
fi
done
rm *.tra