Prusa-Firmware/lang/lang-add.sh

73 lines
1.8 KiB
Bash
Raw Normal View History

2019-07-26 15:53:08 +00:00
#!/bin/bash
#
# lang-add.sh - multi-language support script
# add new texts from list (lang_add.txt) to all dictionary files
#
# Input files:
# lang_add.txt
# Updated files:
# lang_en.txt and all lang_en_xx.txt
2018-11-01 18:00:49 +00:00
#
# insert single text to english dictionary
# $1 - text to insert
insert_en()
{
#replace '[' and ']' in string with '\[' and '\]'
str=$(echo "$1" | sed "s/\[/\\\[/g;s/\]/\\\]/g")
# extract english texts, merge new text, grep line number
ln=$((cat lang_en.txt; echo "$1") | sed "/^$/d;/^#/d" | sort | grep -n "$str" | sed "s/:.*//")
# calculate position for insertion
ln=$((3*(ln-2)+1))
# insert new text
sed -i "$ln"'i\\' lang_en.txt
sed -i "$ln"'i\'"$1"'\' lang_en.txt
sed -i "$ln"'i\#\' lang_en.txt
}
# insert single text to translated dictionary
# $1 - text to insert
# $2 - sufix
insert_xx()
{
#replace '[' and ']' in string with '\[' and '\]'
str=$(echo "$1" | sed "s/\[/\\\[/g;s/\]/\\\]/g")
# extract english texts, merge new text, grep line number
ln=$((cat lang_en_$2.txt; echo "$1") | sed "/^$/d;/^#/d" | sed -n 'p;n' | sort | grep -n "$str" | sed "s/:.*//")
# calculate position for insertion
ln=$((4*(ln-2)+1))
# insert new text
sed -i "$ln"'i\\' lang_en_$2.txt
sed -i "$ln"'i\"\x00"\' lang_en_$2.txt
sed -i "$ln"'i\'"$1"'\' lang_en_$2.txt
sed -i "$ln"'i\#\' lang_en_$2.txt
}
# check if input file exists
if ! [ -e lang_add.txt ]; then
echo "file lang_add.txt not found"
exit 1
fi
cat lang_add.txt | sed 's/^/"/;s/$/"/' | while read new_s; do
2019-10-23 10:44:11 +00:00
if grep "$new_s" lang_en.txt >/dev/null; then
echo "text already exist:"
echo "$new_s"
echo
else
echo "adding text:"
echo "$new_s"
echo
insert_en "$new_s"
insert_xx "$new_s" 'cz'
2018-11-01 18:00:49 +00:00
insert_xx "$new_s" 'de'
insert_xx "$new_s" 'es'
insert_xx "$new_s" 'fr'
insert_xx "$new_s" 'it'
insert_xx "$new_s" 'pl'
fi
done
MK3 3 9 0 missing translations (#2646) * Add and update missing translations - updated in Firmware/ files the missing `c=xx` column and `r=yy` rows. - added missing translations to lang/lang_en*.txt Everyone is developing and adding messages to serial and especially to LCD PLEASE add `//// c=xx` or `//// c=xx r=yy` comments. Preparing translations files without that information is a pain in the ... and takes way more time for somebody else to review to code as it would take you. * No need to have `MSG_abcde` again in comments `////` in `messages.c` * German translation * Missed a space * Use the same format as somewhere else * French translation. I am not a native French speaking person, so please excuse my mistakes I may have done. * Spanish translation. I am not a native Spanish speaking person, so please excuse my mistakes I may have done. * CZ translation * Fix typos * Another fix It is Dimmwert and not Dim Wert * Fix issues reported by `lang-check.py` * Add "difficult" messages containing `%` * Updated MSG and German translation * removed a translation as it breaks the language selection * No need to wait until any-key is pressed * No need to wait any-key is pressed * Fixed two LF issues * Updated PO files ready to be send to translators * Add missing italian translations * Improve some existing italian translations * More italian fixes * More italian fixes * Add exceptions in editorconfig for po files to avoid recoding * Fix typo Thanks @DRracer for pointing out * Italian translation by @wavexx * Update po/new/*.po files * Update after merging MK3 branch * Update French translation and some c=xx comments Big thanks to @awenelo @carlin57 for helping with the french translations and their comments. * Update po files after French translation * Fixed most `lang-check.py` reported translation errors for Czech and German. Two Czech have to be reviewed as these are too long. One German is correct as it is shown in c=20 r=2 but is 1 char longer than this to split the message. One German translation seams to be to long but have to review the actual max length * Fix `lang-check.py` Spanish translation errors There have been quite lot TOO long messages, Can't imagine that nobody every complained about that. * Fix `lang-check.py` Italian translations errors * Update not_tran and not_used files after fixing several translations * Some more error fixes and update of `po` files * Polish translation * Czech updated * Fix typo * no need to translate `\x00` if it is the same * Polish: Runouts->Koniec * Polish: Runouts->Konce f ... hopefully the last change * Added MK2.5/s auto power mode to eeprom doxygen * Final updates. - Compiled all versions with multi-languages - Compiled all versions with EN_ONLY - updated all /lang/po/Firmware*.* files * Add crlf attributes for po files As done for editorconfig, this similarly forces git to handle po files consistently in DOS format. * Further improvent of IT translations * Updated translation Added cleanup to PF-build.sh * remove lang/not_tran* and lang/not_used mistakenly added into the PR Co-authored-by: DRracer <drracer@seznam.cz> Co-authored-by: Yuri D'Elia <wavexx@thregr.org> Co-authored-by: D.R.racer <drracer@drracer.eu>
2020-05-12 20:23:40 +00:00
read -t 5
exit 0