mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 06:52:39 +03:00
Added 'fixtrans' build option
This commit is contained in:
parent
2895250014
commit
d45efbddad
2 changed files with 45 additions and 1 deletions
5
README
5
README
|
@ -176,6 +176,11 @@ configuration to the build. These are:
|
||||||
are correct by looking at the build output - assume the metadata
|
are correct by looking at the build output - assume the metadata
|
||||||
is correct. This takes away a useful level of sanity checking, and
|
is correct. This takes away a useful level of sanity checking, and
|
||||||
should only be used if the values can't be extracted.
|
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.
|
||||||
|
|
||||||
Another example, using extra parameters:
|
Another example, using extra parameters:
|
||||||
|
|
||||||
|
|
41
build.py
41
build.py
|
@ -247,6 +247,45 @@ 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 translation files if necessary...
|
||||||
|
if thisbuild.has_key('fixtrans') and thisbuild['fixtrans'] == 'yes':
|
||||||
|
for root, dirs, files in os.walk(os.path.join(root_dir,'res')):
|
||||||
|
for filename in files:
|
||||||
|
if filename.endswith('.xml'):
|
||||||
|
f = open(os.path.join(root, filename))
|
||||||
|
changed = False
|
||||||
|
outlines = []
|
||||||
|
for line in f:
|
||||||
|
num = 1
|
||||||
|
index = 0
|
||||||
|
oldline = line
|
||||||
|
while True:
|
||||||
|
index = line.find("%", index)
|
||||||
|
if index == -1:
|
||||||
|
break
|
||||||
|
next = line[index+1:index+2]
|
||||||
|
if next == "s" or next == "d":
|
||||||
|
line = (line[:index+1] +
|
||||||
|
str(num) + "$" +
|
||||||
|
line[index+1:])
|
||||||
|
num += 1
|
||||||
|
index += 3
|
||||||
|
else:
|
||||||
|
index += 1
|
||||||
|
# We only want to insert the positional arguments
|
||||||
|
# when there is more than one argument...
|
||||||
|
if oldline != line:
|
||||||
|
if num > 2:
|
||||||
|
changed = True
|
||||||
|
else:
|
||||||
|
line = oldline
|
||||||
|
outlines.append(line)
|
||||||
|
f.close()
|
||||||
|
if changed:
|
||||||
|
f = open(os.path.join(root, filename), 'w')
|
||||||
|
f.writelines(outlines)
|
||||||
|
f.close()
|
||||||
|
|
||||||
# Run a pre-build command if one is required...
|
# Run a pre-build command if one is required...
|
||||||
if thisbuild.has_key('prebuild'):
|
if thisbuild.has_key('prebuild'):
|
||||||
if subprocess.call(thisbuild['prebuild'],
|
if subprocess.call(thisbuild['prebuild'],
|
||||||
|
@ -409,7 +448,7 @@ for app in apps:
|
||||||
vercode = re.match(pat, line).group(1)
|
vercode = re.match(pat, line).group(1)
|
||||||
pat = re.compile(".*versionName='([^']*)'.*")
|
pat = re.compile(".*versionName='([^']*)'.*")
|
||||||
version = re.match(pat, line).group(1)
|
version = re.match(pat, line).group(1)
|
||||||
if version == None or versioncode == None:
|
if version == None or vercode == None:
|
||||||
print "Could not find version information in build in output"
|
print "Could not find version information in build in output"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue