diff options
author | Pierre GRANDIN <pgrandin@users.noreply.github.com> | 2018-09-06 04:01:55 -0700 |
---|---|---|
committer | jkoan <jkoan@users.noreply.github.com> | 2018-09-06 13:01:55 +0200 |
commit | 0de598f5f7f560b0df6c9bc213b6e10ae542f6dc (patch) | |
tree | 5b209db28dcc9a521f448718bab70f2fe7ad927f /scripts | |
parent | 07ba7f4bdf0c4689b7f5eb7c3a88e7568b71816a (diff) | |
download | navit-0de598f5f7f560b0df6c9bc213b6e10ae542f6dc.tar.gz |
add:18n:added script to import one launchpad translation via its url (#658)
* add:18n:added script to import one launchpad translation via its url
* Making CodeFactor happier
* Making CodeFactor happier
* removed import_translations.sh, replaced by single-file import script
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/import_translation.sh | 66 | ||||
-rw-r--r-- | scripts/import_translations.sh | 47 |
2 files changed, 66 insertions, 47 deletions
diff --git a/scripts/import_translation.sh b/scripts/import_translation.sh new file mode 100644 index 000000000..d1d1f3a6c --- /dev/null +++ b/scripts/import_translation.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# This script imports one translation from launchpad +# The url to the .po file should be provided as an argument + +if [[ $1 == "" ]]; then + echo "I need the po URL from Launchpad" + exit +fi + +id=$(echo $1|cut -d'/' -f4) +po=$(echo $1|cut -d'/' -f5|cut -c 13-) + +rm -rf navit +git clone git@github.com:navit-gps/navit.git +cd navit/ +[ -d po/import_queue ] && exit -1 +mkdir po/import_queue +i="po/import_queue/$po" +wget $1 -O po/import_queue/$po + +# Let's fix the headers of the .po files in the import queue +for i in po/import_queue/*.po; do + b=$(basename $i) + po=${b#*-} + code=${po%.*} + git checkout -b i18n/$code || exit -1 + lname=$(head -n1 ${i} | sed 's/# \(.*\) translation.\{0,1\} for navit/\1/') + if [[ $lname == "" ]]; then + echo "Cannot find the language name in the header of $i" + exit 1 + fi + d=$(date +"%Y") + echo "# ${lname} translations for navit" > po/${po}.header + echo "# Copyright (C) 2006-${d} The Navit Team" >> po/${po}.header + echo "# This file is distributed under the same license as the navit package." >> po/${po}.header + echo "# Many thanks to the contributors of this translation:" >> po/${po}.header + # Build a clean list of the contributors + IFS=$'\n' + echo "Downloading https://translations.launchpad.net/navit/trunk/+pots/navit/${code}/+details" + contributors=$(wget -q https://translations.launchpad.net/navit/trunk/+pots/navit/${code}/+details -O - | grep -E '^ <a href=".+?" class="sprite person">') + for user in $contributors; do + url=$(echo $user|cut -d'"' -f2) + name=$(echo $user|cut -d'>' -f2|cut -d'<' -f1) + echo "# $name $url" >> po/${po}.header + done + echo '' >> po/${po}.header + echo 'msgid ""' >> po/${po}.header + + # We remove two tags that just generate noise + sed -i '/X-Launchpad-Export-Date/d' ${i} + sed -i '/X-Generator/d' ${i} + sed -i '/POT-Creation-Date/d' ${i} + + # Let's put the translation from launchpad without the header + mv po/${po}.header po/${po}.in + sed '1,/msgid ""/ d' ${i} >> po/${po}.in + + git status + git add po/${po}.in && rm $i + git commit -m "Update:i18n:Updated ${lname} translation from launchpad" po/${po}.in + git diff trunk + echo "Going to push $id/$code in branch i18n/$code, press a key" + read -r + git push --set-upstream origin i18n/${code} +done diff --git a/scripts/import_translations.sh b/scripts/import_translations.sh deleted file mode 100644 index 741c47200..000000000 --- a/scripts/import_translations.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -set -e - -# Let's check if there is files in the import queue -[ -d po/import_queue/ ] || exit 0 - -# Let's fix the headers of the .po files in the import queue -for i in po/import_queue/*.po; do - b=$(basename $i) - po=${b#*-} - code=${po%.*} - git checkout -b i18n/$code - lname=$(head -n1 ${i} | sed 's/# \(.*\) translation.\{0,1\} for navit/\1/') - if [[ $lname == "" ]]; then - echo "Cannot find the language name in the header of $i" - exit 1 - fi - d=$(date +"%Y") - echo "# ${lname} translations for navit" > po/${po}.header - echo "# Copyright (C) 2006-${d} The Navit Team" >> po/${po}.header - echo "# This file is distributed under the same license as the navit package." >> po/${po}.header - echo "# Many thanks to the contributors of this translation:" >> po/${po}.header - # Build a clean list of the contributors - IFS=$'\n' - echo "Downloading https://translations.launchpad.net/navit/trunk/+pots/navit/${code}/+details" - contributors=$(wget -q https://translations.launchpad.net/navit/trunk/+pots/navit/${code}/+details -O - | grep -E '^ <a href=".+?" class="sprite person">') - for user in $contributors; do - url=$(echo $user|cut -d'"' -f2) - name=$(echo $user|cut -d'>' -f2|cut -d'<' -f1) - echo "# $name $url" >> po/${po}.header - done - echo '' >> po/${po}.header - echo 'msgid ""' >> po/${po}.header - - # We remove two tags that just generate noise - sed -i '/X-Launchpad-Export-Date/d' ${i} - sed -i '/X-Generator/d' ${i} - sed -i '/POT-Creation-Date/d' ${i} - - # Let's put the translation from launchpad without the header - mv po/${po}.header po/${po}.in - sed '1,/msgid ""/ d' ${i} >> po/${po}.in - - git add po/${po}.in && rm $i - git commit -m "Updated ${lname} translation from launchpad" po/${po}.in - git push --set-upstream origin i18n/${code} -done |