Added the ability to fix the old apostrophe thing

This commit is contained in:
Ciaran Gultnieks 2011-03-03 20:25:18 +00:00
parent 3b1ad02d01
commit 263e4c4e7b
2 changed files with 32 additions and 15 deletions

33
README
View file

@ -165,31 +165,36 @@ configuration to the build. These are:
that. that.
initfun=yes Enables a selection of mad hacks to make com.funambol.android initfun=yes Enables a selection of mad hacks to make com.funambol.android
build. Probably not useful for any other application. build. Probably not useful for any other application.
buildjni=yes Enables building of native code via the ndk-build script before buildjni=yes Enables building of native code via the ndk-build script
doing the main ant build. before doing the main ant build.
submodules=yes Use if the project (git only) has submodules - causes git submodules=yes Use if the project (git only) has submodules - causes git
submodule init and update to be executed after the source is submodule init and update to be executed after the source is
cloned. cloned.
encoding=xxxx Adds a java.encoding property to local.properties with the given encoding=xxxx Adds a java.encoding property to local.properties with the
value. Generally the value will be 'utf-8'. This is picked up by given value. Generally the value will be 'utf-8'. This is
the SDK's ant rules, and forces the Java compiler to interpret picked up by the SDK's ant rules, and forces the Java
source files with this encoding. If you receive warnings during compiler to interpret source files with this encoding. If
the compile about character encodings, you probably need this. you receive warnings during the compile about character
encodings, you probably need this.
prebuild=xxxx Specifies a shell command (or commands - chain with &&) to prebuild=xxxx Specifies a shell command (or commands - chain with &&) to
run before the build takes place. Backslash can be used run before the build takes place. Backslash can be used
as an escape character to insert literal commas, or as the as an escape character to insert literal commas, or as the
last character on a line to join that line with the next. last character on a line to join that line with the next.
It have no special meaning in other contexts; in particular, It have no special meaning in other contexts; in particular,
literal backslashes should not be escaped. literal backslashes should not be escaped.
novcheck=yes Don't check that the version name and code in the resulting apk novcheck=yes Don't check that the version name and code in the resulting
are correct by looking at the build output - assume the metadata apk are correct by looking at the build output - assume the
is correct. This takes away a useful level of sanity checking, and metadata is correct. This takes away a useful level of
should only be used if the values can't be extracted. sanity checking, and should only be used if the values can't
be extracted.
fixtrans=yes Modifies any instances of string resources that use multiple fixtrans=yes Modifies any instances of string resources that use multiple
formatting arguments, but don't use positional notation. For formatting arguments, but don't use positional notation. For
example, "Hello %s, %d" becomes "Hello %1$s, %2$d". Newer versions example, "Hello %s, %d" becomes "Hello %1$s, %2$d". Newer
of the Android platform tools enforce this sensible standard. If you versions of the Android platform tools enforce this sensible
get error messages relating to that, you need to enable this. standard. If you get error messages relating to that, you
need to enable this.
fixapos=yes Like fixtrans, but deals with an even older issue relating
to 'unescaped apostrophes' in translation strings.
Another example, using extra parameters: Another example, using extra parameters:

View file

@ -252,8 +252,20 @@ for app in apps:
if thisbuild.has_key('rm'): if thisbuild.has_key('rm'):
os.remove(os.path.join(build_dir, thisbuild['rm'])) os.remove(os.path.join(build_dir, thisbuild['rm']))
# Fix apostrophes translation files if necessary...
if thisbuild.get('fixapos', 'no') == 'yes':
for root, dirs, files in os.walk(os.path.join(root_dir,'res')):
for filename in files:
if filename.endswith('.xml'):
if subprocess.call(['sed','-i','s@' +
r"\([^\\]\)'@\1\\'" +
'@g',
os.path.join(root, filename)]) != 0:
print "Failed to amend " + filename
sys.exit(1)
# Fix translation files if necessary... # Fix translation files if necessary...
if thisbuild.has_key('fixtrans') and thisbuild['fixtrans'] == 'yes': if thisbuild.get('fixtrans', 'no') == 'yes':
for root, dirs, files in os.walk(os.path.join(root_dir,'res')): for root, dirs, files in os.walk(os.path.join(root_dir,'res')):
for filename in files: for filename in files:
if filename.endswith('.xml'): if filename.endswith('.xml'):