| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 | #!/bin/bash## lang-import.sh - multi-language support script#  for importing translated xx.poLNG=$1# if no arguments, 'all' is selected (all po and also pot will be generated)if [ -z "$LNG" ]; then LNG=all; fi# if 'all' is selected, script will generate all po files and also pot fileif [ "$LNG" = "all" ]; then ./lang-import.sh cz ./lang-import.sh de ./lang-import.sh es ./lang-import.sh fr ./lang-import.sh it ./lang-import.sh pl#DO NOT add Community languages here !!! exit 0fi# language code (iso639-1) is equal to LNGLNGISO=$LNG# exception for 'cz' (code='cs')if [ "$LNG" = "cz" ]; then LNGISO=cs; fi# cd to input foldercd po/new# check if input file existsif ! [ -e $LNGISO.po ]; then echo "Input file $LNGISO.po not found!" >&2 exit -1fi#convert '\\e' sequencies to 'x1b' and '\\' to '\'cat $LNGISO.po | sed 's/\\e/\\x1b/g;s/\\\\/\\/g' > $LNG'_filtered.po'#replace '\n' with ' ' (single space)sed -i 's/ \\n/ /g;s/\\n/ /g' $LNG'_filtered.po'#replace in czech translationif [ "$LNG" = "cz" ]; then #replace 'ž' with 'z' sed -i 's/\xc5\xbe/z/g' $LNG'_filtered.po' #replace 'ì' with 'e' sed -i 's/\xc4\x9b/e/g' $LNG'_filtered.po' #replace 'í' with 'i' sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po' #replace 'ø' with 'r' sed -i 's/\xc5\x99/r/g' $LNG'_filtered.po' #replace 'è' with 'c' sed -i 's/\xc4\x8d/c/g' $LNG'_filtered.po' #replace 'á' with 'a' sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po' #replace 'é' with 'e' sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'fi#replace in german translation https://en.wikipedia.org/wiki/German_orthographyif [ "$LNG" = "de" ]; then #replace 'ä' with 'ae' sed -i 's/\xc3\xa4/ae/g' $LNG'_filtered.po' #replace 'Ä' with 'Ae' sed -i 's/\xc3\x84/Ae/g' $LNG'_filtered.po' #replace 'ü' with 'ue' sed -i 's/\xc3\xbc/ue/g' $LNG'_filtered.po' #replace 'Ü' with 'Ue' sed -i 's/\xc3\x9c/Ue/g' $LNG'_filtered.po' #replace 'ö' with 'oe' sed -i 's/\xc3\xb6/oe/g' $LNG'_filtered.po' #replace 'Ö' with 'Oe' sed -i 's/\xc3\x96/Oe/g' $LNG'_filtered.po' #replace 'ß' with 'ss' sed -i 's/\xc3\x9f/ss/g' $LNG'_filtered.po'fi#replace in spain translationif [ "$LNG" = "es" ]; then #replace 'á' with 'a' sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po' #replace '¿' with '?' sed -i 's/\xc2\xbf/?/g' $LNG'_filtered.po' #replace 'ó' with 'o' sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po' #replace 'é' with 'e' sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po' #replace 'í' with 'i' sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po' #replace '!' with '!' sed -i 's/\xc2\xa1/!/g' $LNG'_filtered.po' #replace 'n~' with 'n' sed -i 's/\xc3\xb1/n/g' $LNG'_filtered.po'fi#replace in french translation https://en.wikipedia.org/wiki/French_orthographyif [ "$LNG" = "fr" ]; then #replace 'á' with 'a' (right) sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po' #replace 'Á' with 'A' (right) sed -i 's/\xc3\x81/A/g' $LNG'_filtered.po' #replace 'à' with 'a' (left) sed -i 's/\xc3\xa0/a/g' $LNG'_filtered.po' #replace 'À' with 'A' (left) sed -i 's/\xc3\x80/A/g' $LNG'_filtered.po' #replace 'é' with 'e' (right) sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po' #replace 'É' with 'E' (right) sed -i 's/\xc3\x89/E/g' $LNG'_filtered.po' #replace 'è' with 'e' (left) sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po' #replace 'È' with 'E' (left) sed -i 's/\xc3\x88/E/g' $LNG'_filtered.po'fi#replace in italian translationif [ "$LNG" = "it" ]; then #replace 'é' with 'e' (left) sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po' #replace 'á' with 'a' (left) sed -i 's/\xc3\xa0/a/g' $LNG'_filtered.po' #replace 'ó' with 'o' (left) sed -i 's/\xc3\xb2/o/g' $LNG'_filtered.po' #replace 'ú' with 'u' (left) sed -i 's/\xc3\xb9/u/g' $LNG'_filtered.po' #replace 'é' with 'e' sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po' #replace 'É' with 'E' (left) sed -i 's/\xc3\x88/E/g' $LNG'_filtered.po'fi#replace in dutch translation according to https://nl.wikipedia.org/wiki/Accenttekens_in_de_Nederlandse_spellingif [ "$LNG" = "nl" ]; then #replace 'ë' with 'e' sed -i 's/\xc3\xab/e/g' $LNG'_filtered.po' #replace 'ï' with 'i' sed -i 's/\xc3\xaf/i/g' $LNG'_filtered.po' #replace 'é' with 'e' sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po' #replace 'è' with 'e' (left) sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po' #replace 'ö' with 'o' (left) sed -i 's/\xc3\xb6/o/g' $LNG'_filtered.po' #replace 'ê' with 'e' (left) sed -i 's/\xc3\xaa/e/g' $LNG'_filtered.po' #replace 'ü' with 'u' (left) sed -i 's/\xc3\xbc/u/g' $LNG'_filtered.po' #replace 'ç' with 'c' (left) sed -i 's/\xc3\xa7/c/g' $LNG'_filtered.po' #replace 'á' with 'a' (left) sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po' #replace 'à' with 'a' (left) sed -i 's/\xc3\xa0/a/g' $LNG'_filtered.po' #replace 'ä' with 'a' (left) sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po' #replace 'û' with 'u' (left) sed -i 's/\xc3\xbc/u/g' $LNG'_filtered.po' #replace 'î' with 'i' (left) sed -i 's/\xc3\xae/i/g' $LNG'_filtered.po' #replace 'í' with 'i' (left) sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po' #replace 'ô' with 'o' (left) sed -i 's/\xc3\xb4/o/g' $LNG'_filtered.po' #replace 'ú' with 'u' (left) sed -i 's/\xc3\xba/u/g' $LNG'_filtered.po' #replace 'ñ' with 'n' (left) sed -i 's/\xc3\xb1/n/g' $LNG'_filtered.po' #replace 'â' with 'a' (left) sed -i 's/\xc3\xa2/a/g' $LNG'_filtered.po' #replace 'Å' with 'A' (left) sed -i 's/\xc3\x85/A/g' $LNG'_filtered.po'fi#replace in polish translation#if [ "$LNG" = "pl" ]; then#fi#check for nonasci charactersif grep --color='auto' -P -n '[^\x00-\x7F]' $LNG'_filtered.po' >nonasci.txt; then exitfi#join lines with multi-line string constantscat $LNG'_filtered.po' | sed ':a;N;$!ba;s/\x22\n\x22//g' > $LNG'_new.po'#generate new dictionarycat ../../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do /bin/echo -e "$s" if [ "${s:0:1}" = "\"" ]; then#  /bin/echo -e "$s"  s=$(/bin/echo -e "$s")  s2=$(grep -F -A1 -B0  "$s" "$LNG"_new.po | tail -n1 | sed 's/^msgstr //')  if [ -z "$s2" ]; then   echo '"\x00"'  else   echo "$s2"  fi#  echo fidone > lang_en_$LNG.txt
 |