diff options
Diffstat (limited to 'tools/get-translated-release-notes.sh')
-rwxr-xr-x | tools/get-translated-release-notes.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/get-translated-release-notes.sh b/tools/get-translated-release-notes.sh new file mode 100755 index 000000000..e44fcebc6 --- /dev/null +++ b/tools/get-translated-release-notes.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +LANG_FILE=tools/release-notes-language-codes.csv +TMPDIR=/tmp/release-notes +OUTFILE=$TMPDIR/release-notes.md + +function fetch() { + for line in $(cat $LANG_FILE) ; do + code=$(echo $line|cut -d "," -f1|tr -d " ") + local=$(echo $line|cut -d "," -f2|tr -d " ") + echo updating $local - $code + mkdir -p $TMPDIR + curl -sSfL --globoff -o $TMPDIR/strings-$code.xml "http://translate.wordpress.org/projects/apps/android/release-notes/$code/default/export-translations?filters[status]=current&format=android" || (echo Error downloading $code) + done +} + +# Clean up strings by removing starting / trailing whitespaces, convert \n to new lines, etc. +function cleanup() { + sed 's/\\n/|/g' \ + | tr '|' '\n' \ + | sed 's/<[^>]*>//g' \ + | sed -e 's/\\'/'/g' \ + | sed 's/^[[:space:]]*//g' \ + | sed 's/[[:space:]]*$//g' +} + +function extract_release_notes() { + comment=$1 + footer=$2 + rm -f $OUTFILE + for line in $(cat $LANG_FILE) ; do + code=$(echo $line|cut -d "," -f1|tr -d " ") + name=$(echo $line|cut -d "," -f3-|tr -d " ") + echo \# $name >> $OUTFILE + echo >> $OUTFILE + grep \"$comment\" $TMPDIR/strings-$code.xml | cleanup >> $OUTFILE + grep \"$footer\" $TMPDIR/strings-$code.xml | cleanup >> $OUTFILE + echo >> $OUTFILE + done +} + +if [ x"$2" == x ]; then + echo Usage: $0 RELEASE_NOTES_ID FOOTER_ID + echo Example: $0 release_note_35 release_note_footer + exit 1 +fi + +fetch +extract_release_notes $1 $2 +echo Generated file: +echo $OUTFILE |