chiark / gitweb /
Added the ability to fix the old apostrophe thing
authorCiaran Gultnieks <ciaran@ciarang.com>
Thu, 3 Mar 2011 20:25:18 +0000 (20:25 +0000)
committerCiaran Gultnieks <ciaran@ciarang.com>
Thu, 3 Mar 2011 20:25:18 +0000 (20:25 +0000)
README
build.py

diff --git a/README b/README
index 4dc9f58531fcef60e214033d2e78c2ac77590070..75466c8e12d344f91ea130cb04b17066764a2157 100644 (file)
--- a/README
+++ b/README
@@ -165,31 +165,36 @@ configuration to the build. These are:
                    that.
  initfun=yes      Enables a selection of mad hacks to make com.funambol.android
                    build. Probably not useful for any other application.
- buildjni=yes      Enables building of native code via the ndk-build script before
-                   doing the main ant build.
+ buildjni=yes      Enables building of native code via the ndk-build script
+                   before doing the main ant build.
  submodules=yes    Use if the project (git only) has submodules - causes git
                    submodule init and update to be executed after the source is
                    cloned.
- encoding=xxxx     Adds a java.encoding property to local.properties with the given
-                   value. Generally the value will be 'utf-8'. This is picked up by
-                   the SDK's ant rules, and forces the Java compiler to interpret
-                   source files with this encoding. If you receive warnings during
-                   the compile about character encodings, you probably need this.
+ encoding=xxxx     Adds a java.encoding property to local.properties with the
+                   given value. Generally the value will be 'utf-8'. This is
+                   picked up by the SDK's ant rules, and forces the Java
+                   compiler to interpret source files with this encoding. If
+                   you receive warnings during the compile about character
+                   encodings, you probably need this.
  prebuild=xxxx     Specifies a shell command (or commands - chain with &&) to
                    run before the build takes place. Backslash can be used
                    as an escape character to insert literal commas, or as the
                    last character on a line to join that line with the next.
                    It have no special meaning in other contexts; in particular,
                    literal backslashes should not be escaped.
- novcheck=yes      Don't check that the version name and code in the resulting apk
-                   are correct by looking at the build output - assume the metadata
-                   is correct. This takes away a useful level of sanity checking, and
-                   should only be used if the values can't be extracted.
+ novcheck=yes      Don't check that the version name and code in the resulting
+                   apk are correct by looking at the build output - assume the
+                   metadata is correct. This takes away a useful level of
+                   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
                    formatting arguments, but don't use positional notation. For
-                   example, "Hello %s, %d" becomes "Hello %1$s, %2$d". Newer versions
-                   of the Android platform tools enforce this sensible standard. If you
-                   get error messages relating to that, you need to enable this.
+                   example, "Hello %s, %d" becomes "Hello %1$s, %2$d". Newer
+                   versions of the Android platform tools enforce this sensible
+                   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:
 
index 9adcad86c77c1fcf74ae6935e2dd6ca4aa5a7fcb..64fdf14d48ce8cf0f54ac288710a43b99506d084 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -252,8 +252,20 @@ for app in apps:
                 if thisbuild.has_key('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...
-                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 filename in files:
                             if filename.endswith('.xml'):