Prusa-Firmware/lang/lang-import.sh

513 lines
17 KiB
Bash
Raw Normal View History

2019-09-06 06:30:10 +00:00
#!/bin/bash
2018-11-21 12:11:08 +00:00
#
2022-03-12 07:58:24 +00:00
# Version 1.0.1 Build 38
2022-01-11 12:18:48 +00:00
#
2018-11-21 12:11:08 +00:00
# lang-import.sh - multi-language support script
# for importing translated xx.po
2022-01-11 12:18:48 +00:00
#
#############################################################################
# Change log:
# 9 Nov. 2018, XPila, Initial
# 21 Nov. 2018, XPila, fix - replace '\n' with space in all languages
# 10 Dec. 2018, jhoblitt, make all shell scripts executable
# 21 Aug. 2019, 3d-gussner, Added "All" argument and it is default in nothing is chosen
# Added few German/French diacritical characters
# 6 Sep. 2019, DRracer, change to bash
2022-01-11 12:18:48 +00:00
# 14 Sep. 2019, 3d-gussner, Prepare adding new language
# 1 Mar. 2019, 3d-gussner, Move `Dutch` language parts
# Add templates for future community languages
# 17 Dec. 2021, 3d-gussner, Use one config file for all languages
# Fix missing last translation
# Add counter
# replace two double quotes with `\x00`
# 21 Dec. 2021, 3d-gussner, Add Swedish, Danish, Slovanian, Hungarian,
# Luxembourgish, Croatian
# 3 Jan. 2022, 3d-gussner, Add Lithuanian
# Cleanup outaded code
2022-01-11 12:18:48 +00:00
# 11 Jan. 2022, 3d-gussner, Added version and Change log
# colored output
# Add Community language support
# Use `git rev-list --count HEAD lang-import.sh`
2022-01-11 12:18:48 +00:00
# to get Build Nr
# 14 Jan. 2022, 3d-gussner, Replace German UTF-8 'äöÿÿ' to HD44780 A00 ROM 'äöÿÿ'
# 28 Jan. 2022, 3d-gussner, Run lang-check and output `xx-output.txt` file to review
# translations
# new argruments `--information` `--import-check`
2022-02-11 13:18:03 +00:00
# 11 Jan. 2022, ingbrzy, Add Slovak letters
2022-02-11 14:04:35 +00:00
# 11 Feb. 2022, 3d-gussner, Change to python3
# 14 Feb. 2022, 3d-gussner, Replace non-block space with space
# Fix single language run without config.sh OK
2022-03-12 07:58:24 +00:00
# 12 Mar. 2022, 3d-gussner, Update Norwegian replace umlaut and diacritics
2022-01-11 12:18:48 +00:00
#############################################################################
echo "$(tput setaf 2)lang-import.sh started$(tput sgr 0)" >&2
2018-11-21 12:11:08 +00:00
LNG=$1
# if no arguments, 'all' is selected (all po and also pot will be generated)
if [ -z "$LNG" ]; then
LNG=all;
# Config:
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo "$(tput setaf 1)Config NG!$(tput sgr 0)" >&2; exit 1; fi
fi
if [[ ! -z "$COMMUNITY_LANGUAGES" && "$LNG" = "all" ]]; then
LANGUAGES+=" $COMMUNITY_LANGUAGES"
else
LANGUAGES="$LNG"
fi
echo "$(tput setaf 2)lang-import languages:$LANGUAGES$(tput sgr 0)" >&2
# if 'all' is selected, script will generate all po files and also pot file
if [ "$LNG" = "all" ]; then
for lang in $LANGUAGES; do
./lang-import.sh $lang
done
exit 0
fi
2018-11-21 12:11:08 +00:00
# language code (iso639-1) is equal to LNG
LNGISO=$LNG
# exception for 'cz' (code='cs')
if [ "$LNG" = "cz" ]; then LNGISO=cs; fi
# cd to input folder
cd po/new
# check if input file exists
if ! [ -e $LNGISO.po ]; then
2022-01-11 12:18:48 +00:00
echo "$(tput setaf 1)Input file $LNGISO.po not found!$(tput sgr 0)" >&2
2018-11-21 12:11:08 +00:00
exit -1
fi
#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'
2018-11-21 12:11:08 +00:00
#replace in czech translation
if [ "$LNG" = "cz" ]; then
#replace 'Á' with 'A'
sed -i 's/\xc3\x81/A/g' $LNG'_filtered.po'
#replace 'á' with 'a'
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po'
#replace 'Č' with 'C'
sed -i 's/\xc4\x8c/C/g' $LNG'_filtered.po'
#replace 'č' with 'c'
sed -i 's/\xc4\x8d/c/g' $LNG'_filtered.po'
#replace 'Ď' with 'D'
sed -i 's/\xc4\x8e/D/g' $LNG'_filtered.po'
#replace 'ď' with 'd'
sed -i 's/\xc4\x8f/d/g' $LNG'_filtered.po'
#replace 'É' with 'E'
sed -i 's/\xc3\x89/E/g' $LNG'_filtered.po'
#replace 'é' with 'e'
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
#replace 'Ě' with 'E'
sed -i 's/\xc4\x9a/E/g' $LNG'_filtered.po'
#replace 'ě' with 'e'
sed -i 's/\xc4\x9b/e/g' $LNG'_filtered.po'
#replace 'Í' with 'I'
sed -i 's/\xc3\x8d/I/g' $LNG'_filtered.po'
#replace 'í' with 'i'
sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po'
#replace 'Ň' with 'N'
sed -i 's/\xc5\x87/N/g' $LNG'_filtered.po'
#replace 'ň' with 'n'
sed -i 's/\xc5\x88/n/g' $LNG'_filtered.po'
#replace 'Ó' with 'O'
sed -i 's/\xc3\x93/O/g' $LNG'_filtered.po'
#replace 'ó' with 'o'
sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po'
#replace 'Ř' with 'R'
sed -i 's/\xc5\x98/R/g' $LNG'_filtered.po'
#replace 'ř' with 'r'
sed -i 's/\xc5\x99/r/g' $LNG'_filtered.po'
#replace 'Š' with 'S'
sed -i 's/\xc5\xa0/S/g' $LNG'_filtered.po'
#replace 'š' with 's'
sed -i 's/\xc5\xa1/s/g' $LNG'_filtered.po'
#replace 'Ť' with 'T'
sed -i 's/\xc5\xa4/T/g' $LNG'_filtered.po'
#replace 'ť' with 't'
sed -i 's/\xc5\xa5/t/g' $LNG'_filtered.po'
#replace 'Ú' with 'U'
sed -i 's/\xc3\x9a/U/g' $LNG'_filtered.po'
#replace 'ú' with 'u'
sed -i 's/\xc3\xba/u/g' $LNG'_filtered.po'
#replace 'Ů' with 'U'
sed -i 's/\xc5\xae/U/g' $LNG'_filtered.po'
#replace 'ů' with 'u'
sed -i 's/\xc5\xaf/u/g' $LNG'_filtered.po'
#replace 'Ý' with 'Y'
sed -i 's/\xc3\x9d/Y/g' $LNG'_filtered.po'
#replace 'ý' with 'y'
sed -i 's/\xc3\xbd/y/g' $LNG'_filtered.po'
#replace 'Ž' with 'Z'
sed -i 's/\xc5\xbd/Z/g' $LNG'_filtered.po'
#replace 'ž' with 'z'
sed -i 's/\xc5\xbe/z/g' $LNG'_filtered.po'
2018-11-21 12:11:08 +00:00
fi
2022-02-22 05:58:37 +00:00
#replace in German translation https://en.wikipedia.org/wiki/German_orthography
#replace in Swedish as well
if [[ "$LNG" = "de" || "$LNG" = "sv" ]]; then
#replace UTF-8 'äöüß' to HD44780 A00 'äöüß'
#replace 'ä' with 'A00 ROM ä'
sed -i 's/\xc3\xa4/\\xe1/g' $LNG'_filtered.po'
#replace 'Ä' with 'A00 ROM ä'
sed -i 's/\xc3\x84/\\xe1/g' $LNG'_filtered.po'
#replace 'ü' with 'A00 ROM ü'
sed -i 's/\xc3\xbc/\\xf5/g' $LNG'_filtered.po'
#replace 'Ü' with 'A00 ROM ü'
sed -i 's/\xc3\x9c/\\xf5/g' $LNG'_filtered.po'
#replace 'ö' with 'A00 ROM ö'
sed -i 's/\xc3\xb6/\\xef/g' $LNG'_filtered.po'
#replace 'Ö' with 'A00 ROM ö'
sed -i 's/\xc3\x96/\\xef/g' $LNG'_filtered.po'
#replace 'ß' with 'A00 ROM ß'
sed -i 's/\xc3\x9f/\\xe2/g' $LNG'_filtered.po'
2018-11-21 12:11:08 +00:00
fi
#replace in spain translation
if [ "$LNG" = "es" ]; then
#replace 'á' with 'a'
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po'
#replace '¿' with '?'
2018-11-21 12:11:08 +00:00
sed -i 's/\xc2\xbf/?/g' $LNG'_filtered.po'
#replace 'ó' with 'o'
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po'
#replace 'é' with 'e'
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
#replace 'í' with 'i'
2018-11-21 12:11:08 +00:00
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_orthography
2018-11-21 12:11:08 +00:00
if [ "$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)
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
#replace 'É' with 'E' (right)
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\x89/E/g' $LNG'_filtered.po'
#replace 'è' with 'e' (left)
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po'
#replace 'È' with 'E' (left)
sed -i 's/\xc3\x88/E/g' $LNG'_filtered.po'
2018-11-21 12:11:08 +00:00
fi
#replace in italian translation
if [ "$LNG" = "it" ]; then
#replace 'é' with 'e' (left)
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po'
#replace 'á' with 'a' (left)
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xa0/a/g' $LNG'_filtered.po'
#replace 'ó' with 'o' (left)
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xb2/o/g' $LNG'_filtered.po'
#replace 'ú' with 'u' (left)
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xb9/u/g' $LNG'_filtered.po'
#replace 'é' with 'e'
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
#replace 'É' with 'E' (left)
2018-11-21 12:11:08 +00:00
sed -i 's/\xc3\x88/E/g' $LNG'_filtered.po'
fi
2019-09-14 13:49:33 +00:00
#replace in dutch translation according to https://nl.wikipedia.org/wiki/Accenttekens_in_de_Nederlandse_spelling
if [ "$LNG" = "nl" ]; then
#replace 'ë' with 'e'
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xab/e/g' $LNG'_filtered.po'
#replace 'ï' with 'i'
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xaf/i/g' $LNG'_filtered.po'
#replace 'é' with 'e'
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
#replace 'è' with 'e' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po'
#replace 'ö' with 'o' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xb6/o/g' $LNG'_filtered.po'
#replace 'ê' with 'e' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xaa/e/g' $LNG'_filtered.po'
#replace 'ü' with 'u' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xbc/u/g' $LNG'_filtered.po'
#replace 'ç' with 'c' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xa7/c/g' $LNG'_filtered.po'
#replace 'á' with 'a' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po'
#replace 'à' with 'a' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xa0/a/g' $LNG'_filtered.po'
#replace 'ä' with 'a' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
#replace 'û' with 'u' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xbc/u/g' $LNG'_filtered.po'
#replace 'î' with 'i' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xae/i/g' $LNG'_filtered.po'
#replace 'í' with 'i' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po'
#replace 'ô' with 'o' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xb4/o/g' $LNG'_filtered.po'
#replace 'ú' with 'u' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xba/u/g' $LNG'_filtered.po'
#replace 'ñ' with 'n' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xb1/n/g' $LNG'_filtered.po'
#replace 'â' with 'a' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\xa2/a/g' $LNG'_filtered.po'
#replace 'Å' with 'A' (left)
2019-09-14 13:49:33 +00:00
sed -i 's/\xc3\x85/A/g' $LNG'_filtered.po'
fi
if [ "$LNG" = "sv" ]; then
2022-02-23 05:38:45 +00:00
#repace 'Å' with 'A'
2022-03-09 05:37:15 +00:00
sed -i 's/\xc3\x85/A/g' $LNG'_filtered.po'
2022-02-23 05:38:45 +00:00
#repace 'å' with 'a'
2022-03-09 05:37:15 +00:00
sed -i 's/\xc3\xA5/a/g' $LNG'_filtered.po'
2021-12-21 13:33:35 +00:00
fi
2022-02-22 10:56:01 +00:00
#https://en.wikipedia.org/wiki/Norwegian_orthography éèêóòôù ÅåÆæØø
if [ "$LNG" = "no" ]; then
2022-03-12 07:58:24 +00:00
#replace UTF-8 'æÆøØ' to HD44780 A00 'äö'
2022-02-22 10:56:01 +00:00
#repace 'Æ' with 'Ae'
sed -i 's/\xc3\x86/\\xe1/g' $LNG'_filtered.po'
2022-02-22 10:56:01 +00:00
#repace 'æ' with 'ae'
sed -i 's/\xc3\xa6/\\xe1/g' $LNG'_filtered.po'
2022-02-22 10:56:01 +00:00
#repace 'Ø' with 'O'
sed -i 's/\xc3\x98/\\xef/g' $LNG'_filtered.po'
2022-02-22 10:56:01 +00:00
#repace 'ø' with 'o'
sed -i 's/\xc3\xb8/\\xef/g' $LNG'_filtered.po'
2022-03-12 07:58:24 +00:00
#replace diacritics
#repace 'Å' with 'A'
sed -i 's/\xc3\x85/A/g' $LNG'_filtered.po'
#repace 'å' with 'a'
sed -i 's/\xc3\xa5/a/g' $LNG'_filtered.po'
2022-02-22 10:56:01 +00:00
#replace 'é' with 'e'
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
#replace 'è' with 'e'
sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po'
#replace 'ê' with 'e'
sed -i 's/\xc3\xaa/e/g' $LNG'_filtered.po'
#replace 'ó' with 'o'
sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po'
#replace 'ò' with 'o'
sed -i 's/\xc3\xb2/o/g' $LNG'_filtered.po'
#replace 'ô' with 'o'
sed -i 's/\xc3\xb4/o/g' $LNG'_filtered.po'
#replace 'ù' with 'u'
sed -i 's/\xc3\xb9/u/g' $LNG'_filtered.po'
fi
if [ "$LNG" = "da" ]; then
#repace 'Å' with 'Aa'
2021-12-21 14:15:23 +00:00
sed -i 's/\xc3\x85/Aa/g' $LNG'_filtered.po'
#repace 'å' with 'aa'
2021-12-21 14:15:23 +00:00
sed -i 's/\xc3\xA5/aa/g' $LNG'_filtered.po'
fi
if [ "$LNG" = "sl" ]; then
#replace 'ë' with 'e'
2021-12-21 14:24:06 +00:00
sed -i 's/\xc3\xab/e/g' $LNG'_filtered.po'
#replace 'ä' with 'a' (left)
2021-12-21 14:24:06 +00:00
sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
#replace 'é' with 'e'
2021-12-21 14:24:06 +00:00
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
fi
if [ "$LNG" = "hu" ]; then # See https://www.fileformat.info/info/charset/UTF-8/list.htm
#replace 'Á' with 'A'(acute)
sed -i 's/\xc3\x81/A/g' $LNG'_filtered.po'
#replace 'á' with 'a'
sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po'
#replace 'É' with 'E' (acute)
sed -i 's/\xc3\x89/E/g' $LNG'_filtered.po'
#replace 'é' with 'e'
2021-12-21 14:28:33 +00:00
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
#replace 'Í' with 'I' (acute)
sed -i 's/\xc3\x8d/I/g' $LNG'_filtered.po'
#replace 'i̇́' with 'i'
sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po'
#replace 'Ó' with 'O' (acute)
sed -i 's/\xc3\x93/O/g' $LNG'_filtered.po'
#replace 'ó' with 'o'
sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po'
#replace 'Ö' with 'O' (diaresis)
sed -i 's/\xc3\x96/O/g' $LNG'_filtered.po'
#replace 'ö' with 'o'
sed -i 's/\xc3\xb6/o/g' $LNG'_filtered.po'
#replace 'Ő' with 'O' (double acute)
sed -i 's/\xc5\x90/O/g' $LNG'_filtered.po'
#replace 'ő' with 'o'
sed -i 's/\xc5\x91/o/g' $LNG'_filtered.po'
#replace 'Ú' with 'U' (acute)
sed -i 's/\xc3\x9a/U/g' $LNG'_filtered.po'
#replace 'ú' with 'u'
sed -i 's/\xc3\xba/u/g' $LNG'_filtered.po'
#replace 'Ü' with 'U' (diaersis)
sed -i 's/\xc3\x9c/U/g' $LNG'_filtered.po'
#replace 'ü' with 'u'
sed -i 's/\xc3\xbc/u/g' $LNG'_filtered.po'
#replace 'Ű' with 'U' (double acute)
sed -i 's/\xc5\xb0/U/g' $LNG'_filtered.po'
#replace 'ű' with 'u'
sed -i 's/\xc5\xb1/u/g' $LNG'_filtered.po'
2021-12-21 14:28:33 +00:00
fi
if [ "$LNG" = "lb" ]; then
#replace 'ë' with 'e'
2021-12-21 14:32:54 +00:00
sed -i 's/\xc3\xab/e/g' $LNG'_filtered.po'
#replace 'ä' with 'a'
2021-12-21 14:32:54 +00:00
sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
#replace 'é' with 'e'
2021-12-21 14:32:54 +00:00
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
fi
if [ "$LNG" = "hr" ]; then
#replace 'ë' with 'e'
2021-12-21 14:36:34 +00:00
sed -i 's/\xc3\xab/e/g' $LNG'_filtered.po'
#replace 'ä' with 'a'
2021-12-21 14:36:34 +00:00
sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
#replace 'é' with 'e'
2021-12-21 14:36:34 +00:00
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
fi
2022-01-03 14:00:45 +00:00
if [ "$LNG" = "lt" ]; then
#replace 'ë' with 'e'
2022-01-03 14:00:45 +00:00
sed -i 's/\xc3\xab/e/g' $LNG'_filtered.po'
#replace 'ä' with 'a'
2022-01-03 14:00:45 +00:00
sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
#replace 'é' with 'e'
2022-01-03 14:00:45 +00:00
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
fi
2018-11-21 12:11:08 +00:00
#replace in polish translation
#if [ "$LNG" = "pl" ]; then
#fi
2022-02-10 18:01:04 +00:00
#replace in slovak translation
2022-02-11 13:18:03 +00:00
if [ "$LNG" = "sk" ]; then
#replace 'Á' with 'A'
sed -i 's/\xc3\x81/A/g' $LNG'_filtered.po'
#replace 'á' with 'a'
sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po'
#replace 'ä' with 'a'
sed -i 's/\xc3\xa4/a/g' $LNG'_filtered.po'
#replace 'Č' with 'C'
sed -i 's/\xc4\x8c/C/g' $LNG'_filtered.po'
#replace 'č' with 'c'
sed -i 's/\xc4\x8d/c/g' $LNG'_filtered.po'
#replace 'Ď' with 'D'
sed -i 's/\xc4\x8e/D/g' $LNG'_filtered.po'
#replace 'ď' with 'd'
sed -i 's/\xc4\x8f/d/g' $LNG'_filtered.po'
#replace 'É' with 'E'
sed -i 's/\xc3\x89/E/g' $LNG'_filtered.po'
#replace 'é' with 'e'
sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po'
#replace 'Í' with 'I'
sed -i 's/\xc3\x8d/I/g' $LNG'_filtered.po'
#replace 'í' with 'i'
sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po'
#replace 'ľ' with 'l'
sed -i 's/\xc4\xbe/l/g' $LNG'_filtered.po'
#replace 'Ľ' with 'L'
sed -i 's/\xc4\xbd/L/g' $LNG'_filtered.po'
#replace 'Ň' with 'N'
sed -i 's/\xc5\x87/N/g' $LNG'_filtered.po'
#replace 'ň' with 'n'
sed -i 's/\xc5\x88/n/g' $LNG'_filtered.po'
#replace 'Ó' with 'O'
sed -i 's/\xc3\x93/O/g' $LNG'_filtered.po'
#replace 'ó' with 'o'
sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po'
2022-02-13 07:27:20 +00:00
#replace 'ô' with 'o'
sed -i 's/\xc3\xb4/o/g' $LNG'_filtered.po'
2022-02-11 13:18:03 +00:00
#replace 'Ô' with 'O'
2022-02-13 07:27:20 +00:00
sed -i 's/\xc3\x94/O/g' $LNG'_filtered.po'
2022-02-11 13:18:03 +00:00
#replace 'ŕ' with 'r'
sed -i 's/\xc5\x95/r/g' $LNG'_filtered.po'
#replace 'Ŕ' with 'R'
sed -i 's/\xc5\x94/R/g' $LNG'_filtered.po'
#replace 'Š' with 'S'
sed -i 's/\xc5\xa0/S/g' $LNG'_filtered.po'
#replace 'š' with 's'
sed -i 's/\xc5\xa1/s/g' $LNG'_filtered.po'
#replace 'Ť' with 'T'
sed -i 's/\xc5\xa4/T/g' $LNG'_filtered.po'
#replace 'ť' with 't'
sed -i 's/\xc5\xa5/t/g' $LNG'_filtered.po'
#replace 'Ú' with 'U'
sed -i 's/\xc3\x9a/U/g' $LNG'_filtered.po'
#replace 'ú' with 'u'
sed -i 's/\xc3\xba/u/g' $LNG'_filtered.po'
#replace 'Ý' with 'Y'
sed -i 's/\xc3\x9d/Y/g' $LNG'_filtered.po'
#replace 'ý' with 'y'
sed -i 's/\xc3\xbd/y/g' $LNG'_filtered.po'
#replace 'Ž' with 'Z'
sed -i 's/\xc5\xbd/Z/g' $LNG'_filtered.po'
#replace 'ž' with 'z'
sed -i 's/\xc5\xbe/z/g' $LNG'_filtered.po'
fi
2022-02-10 18:01:04 +00:00
#replace UTF-8 'μ' to HD44780 A00 'μ'
#replace 'μ' with 'A00 ROM μ'
sed -i 's/\xce\xbc/\\xe4/g' $LNG'_filtered.po'
#replace non-break space with space
sed -i 's/\xc2\xa0/ /g' $LNG'_filtered.po'
2022-02-03 07:07:07 +00:00
#check for nonasci characters except HD44780 ROM A00 'äöüß'
if grep --color='auto' -P -n '[^\x00-\x7F]' $LNG'_filtered.po' >nonascii.txt; then
2018-11-21 12:11:08 +00:00
exit
fi
#join lines with multi-line string constants
cat $LNG'_filtered.po' | sed ':a;N;$!ba;s/\x22\n\x22//g' > $LNG'_new.po'
#Get counter from po files
CNTTXT=$(grep '^# MSG' -c $LNGISO.po)
num=1
2022-01-11 12:18:48 +00:00
echo " selected language=$(tput setaf 2)$LNGISO$(tput sgr 0)" >&2
2018-11-21 12:11:08 +00:00
#generate new dictionary
cat ../../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do
/bin/echo -e "$s"
#echo "s = $s ." >&2
2018-11-21 12:11:08 +00:00
if [ "${s:0:1}" = "\"" ]; then
2018-11-21 12:11:08 +00:00
# /bin/echo -e "$s"
s=$(/bin/echo -e "$s")
s2=$(grep -F -A1 -B0 "msgid $s" "$LNG"_new.po | tail -n1 | sed 's/^msgstr //')
2018-11-21 12:11:08 +00:00
if [ -z "$s2" ]; then
2022-01-11 12:18:48 +00:00
echo -ne " processing $num of $CNTTXT\033[0K\r" >&2
2018-11-21 12:11:08 +00:00
echo '"\x00"'
num=$((num+1))
2018-11-21 12:11:08 +00:00
else
2022-01-11 12:18:48 +00:00
echo -ne " processing $num of $CNTTXT\033[0K\r" >&2
2018-11-21 12:11:08 +00:00
echo "$s2"
num=$((num+1))
2018-11-21 12:11:08 +00:00
fi
# echo
fi
2018-11-21 12:11:08 +00:00
done > lang_en_$LNG.txt
2022-01-11 12:18:48 +00:00
echo >&2
echo "$(tput setaf 2)Finished with $LNGISO$(tput sgr 0)" >&2
#replace two double quotes to "\x00"
sed -i 's/""/"\\x00"/g' lang_en_$LNG.txt
#remove CR
sed -i "s/\r//g" lang_en_$LNG.txt
#check new lang
2022-02-11 14:04:35 +00:00
python3 ../../lang-check.py $LNG --warn-empty
python3 ../../lang-check.py $LNG --information >$LNG-output.txt
2022-01-11 12:18:48 +00:00
echo >&2
echo "$(tput setaf 2)lang-import.sh finished$(tput sgr 0)">&2