1#!/usr/local/bin/bash 2 3# generate translation for RELEASE_NOTES.md 4# flag translations to be removed from release 5# 6# 1. Run this script, it just display information (dry-run) 7# ./tools/generate-translations.sh 8# 9# 2. Run with option DO to actually issue the git remove 10# ./tools/generate-translations.sh DO 11# 12# 3. Commit the languages removed for the release. 13# 14# 4. Run again the tool without DO option: 15# 16# ./tools/generate-translations.sh 17# 18# At this point only the kept languages are displayed, and the text can 19# be copy/pasted directly at the end of RELEASE_NOTES.md 20# 21 22CDPATH= 23 24MAX_UNTRANSLATED=20 25MAX_FUZZY_TRANSLATIONS=50 26 27declare -A LANG_NAME=( [af]=Afrikaans 28 [fr]=French 29 [al]=Albanian 30 [ca]=Catalan 31 [cs]=Czech 32 [da]=Danish 33 [de]=German 34 [el]=Greek 35 [es]="European Spanish" 36 [eo]=Esperanto 37 [fi]=Finnish 38 [gl]=Galician 39 [he]=Hebrew 40 [hu]=Hungarian 41 [it]=Italian 42 [ja]=Japanese 43 [nb]="Norwegian Bokmål" 44 [nl]=Dutch 45 [pl]=Polish 46 [pt_BR]="Brazilian Portuguese" 47 [pt_PT]="European Portuguese" 48 [ro]=Romanian 49 [ru]=Russian 50 [sk]=Slovak 51 [sl]=Slovenian 52 [sq]=Albanian 53 [sr@latin]="Serbian Latin" 54 [sr]="Serbian Cyrilic" 55 [sv]=Swedish 56 [th]=Thai 57 [uk]=Ukrainian 58 [zh_CN]="Chinese - China" 59 [zh_TW]="Chinese - Taiwan" ) 60 61 62 63function lang-name() 64{ 65 local CODE=$1 66 echo ${LANG_NAME[$CODE]} 67} 68 69function check-lang() 70{ 71 local CODE=$(echo $1 | cut -d: -f1) 72 local LINE="$2" 73 74 local T=0 75 local FT=0 76 local UT=0 77 78 T=$(echo $LINE | sed 's/\([0-9]*\) translated.*/\1/g') 79 80 echo $LINE | grep -q fuzzy 81 [ $? == 0 ] && FT=$(echo $LINE | sed 's/.* \([0-9]*\) fuzzy.*/\1/g') 82 83 echo $LINE | grep -q untranslated 84 [ $? == 0 ] && UT=$(echo $LINE | sed 's/.* \([0-9]*\) untranslated.*/\1/g') 85 86 if [ $FT -gt $MAX_FUZZY_TRANSLATIONS -o $UT -gt $MAX_UNTRANSLATED ]; then 87 echo -n "remove language $CODE - $(lang-name $CODE): " 1>&2 88 echo "fuzzy $FT, untranslated $UT" 1>&2 89 if [ $DO == YES ]; then 90 git rm $CODE.po 91 else 92 echo "$ git rm $CODE.po" 1>&2 93 fi 94 95 else 96 echo "- $(lang-name $CODE)" 97 fi 98} 99 100if [ "$1" == "DO" ]; then 101 DO=YES 102else 103 DO=NO 104fi 105 106cd po 107 108echo "## Translations" 109 110intltool-update -r 2>&1 | grep -e '[^:]: [0-9]' > ../INTL.OUT 111git restore *.po 112 113cat ../INTL.OUT | 114 while read CODE LINE; do 115 check-lang $CODE "$LINE" 116 done 117 118# rm ../INTL.OUT 119