mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Add script to fix up the files we pull from Transifex
This commit is contained in:
parent
420e6a91be
commit
6267f1249b
11
tools/fix_all_transifex_output.sh
Executable file
11
tools/fix_all_transifex_output.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT=$(readlink -f $0)
|
||||||
|
SCRIPTPATH=`dirname $SCRIPT`
|
||||||
|
PROJECTROOT=`dirname $SCRIPTPATH`
|
||||||
|
|
||||||
|
cd $PROJECTROOT
|
||||||
|
|
||||||
|
find res/values-* -name "strings.xml" -type f -exec ./tools/fix_transifex_output.sh {} \;
|
||||||
|
|
||||||
|
cd -
|
23
tools/fix_transifex_output.sh
Executable file
23
tools/fix_transifex_output.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# What we get from Transifex is unusable and needs some fixing before we're able to use
|
||||||
|
# the translations.
|
||||||
|
|
||||||
|
FILE=$1
|
||||||
|
|
||||||
|
# Fix xliff tags
|
||||||
|
perl -i -pe 's/<xliff:g id=\\?"(.*?)?\\?">/<xliff:g id="\1">/g' $FILE
|
||||||
|
perl -i -pe 's/<\/xliff:g>/<\/xliff:g>/g' $FILE
|
||||||
|
|
||||||
|
# Escape single and double quotes before and after xliff tags
|
||||||
|
perl -i -pe 's/([^\\])(["'\''])<xliff/\1\\\2<xliff/g' $FILE
|
||||||
|
perl -i -pe 's/xliff:g>(["'\''])/xliff:g>\\\1/g' $FILE
|
||||||
|
|
||||||
|
# Restore "<" and ">"
|
||||||
|
perl -i -pe 's/&(lt|gt);/&\1;/g' $FILE
|
||||||
|
|
||||||
|
# <string ...></string> -> <string ... />
|
||||||
|
perl -i -pe 's/"><\/string>/"\/>/g' $FILE
|
||||||
|
|
||||||
|
# Escape single and double quotes (but not in comments or the xml tag)
|
||||||
|
perl -i -pe 's/([^\\])'\''/\1\\'\''/g unless /(<!--|xml)/' $FILE
|
Loading…
Reference in New Issue
Block a user