Commit 61d0c4d8 authored by Vladislav's avatar Vladislav

po_file for LANGUAGE en now use .pot file

parent 34b8e0d5
...@@ -103,9 +103,11 @@ generate_pot () { ...@@ -103,9 +103,11 @@ generate_pot () {
sed 's/{translations\[/(gettext \"/g' setup.sh > setup.sh_tmp sed 's/{translations\[/(gettext \"/g' setup.sh > setup.sh_tmp
sed -i 's/]}/")/g' setup.sh_tmp sed -i 's/]}/")/g' setup.sh_tmp
#fixes когда присходит предупреждение: синтаксис $"..." запрещен по соображениям безопасности; используйте eval_gettext
#Когда присходит предупреждение: синтаксис $"..." запрещен по соображениям безопасности; используйте eval_gettext
#удаляется строка без переводов и этим предупреждением (сейчас их всего 3) #удаляется строка без переводов и этим предупреждением (сейчас их всего 3)
sed -i '/basename_portwine_exe/d' functions_helper_tmp sed -i '/basename_portwine_exe/d' functions_helper_tmp
for lang in $LANGUAGES_LIST for lang in $LANGUAGES_LIST
do do
echo "${lang}" echo "${lang}"
...@@ -146,40 +148,48 @@ TRANSLATIONS_VER=$scripts_install_ver ...@@ -146,40 +148,48 @@ TRANSLATIONS_VER=$scripts_install_ver
declare -A translations=( declare -A translations=(
EOF EOF
if [[ $LANGUAGE == "en" ]] ; then if [[ $LANGUAGE == "en" ]] ; then
po_file="${PORT_WINE_PATH}/data/locales/ru/LC_MESSAGES/PortProton.po" po_file="${PORT_WINE_PATH}/data/locales/PortProton.pot"
else else
po_file="${PORT_WINE_PATH}/data/locales/$LANGUAGE/LC_MESSAGES/PortProton.po" po_file="${PORT_WINE_PATH}/data/locales/$LANGUAGE/LC_MESSAGES/PortProton.po"
fi fi
while IFS= read -r line ; do while IFS= read -r line ; do
while [[ "$line" =~ msgid ]] ; do while [[ $line =~ msgid ]] ; do
unset msgid unset msgid
msgid="$line" msgid="$line"
read -r line read -r line
while [[ ! "$line" =~ msgstr ]] ; do while [[ ! $line =~ msgstr ]] ; do
msgid+="$line" msgid+="$line"
read -r line read -r line
done done
if [[ "$line" =~ msgstr ]]; then if [[ $line =~ msgstr ]]; then
if [[ $LANGUAGE == "en" ]] ; then if [[ $LANGUAGE == "en" ]] ; then
if [[ $msgid == "msgid \"\"" ]] ; then
continue
fi
msgstr="$msgid" msgstr="$msgid"
else else
unset msgstr unset msgstr
msgstr="$line" msgstr="$line"
read -r line read -r line
while [[ ! "$line" =~ msgid ]] ; do while [[ ! $line =~ msgid ]] ; do
msgstr+="$line" msgstr+=$line
read -r line read -r line
if [[ $line == "" ]] ; then
break
fi
done done
fi fi
fi fi
if [[ $LANGUAGE != "en" ]] ; then
msgstr=${msgstr//"msgstr "/} msgstr=${msgstr//"msgstr "/}
msgid=${msgid//"msgid "/}
fi
msgstr=${msgstr//" "/-_-} msgstr=${msgstr//" "/-_-}
msgstr=${msgstr//"\n"\"\"/+_+} msgstr=${msgstr//"\n"\"\"/+_+}
msgstr=${msgstr//\"\"/} msgstr=${msgstr//\"\"/}
msgstr=${msgstr//#*/} msgstr=${msgstr//#*/}
msgstr=${msgstr//"*"/#_#} msgstr=${msgstr//"*"/#_#}
msgid=${msgid//"msgid "/}
msgid=${msgid//" "/-_-} msgid=${msgid//" "/-_-}
msgid=${msgid//"\n"\"\"/+_+} msgid=${msgid//"\n"\"\"/+_+}
msgid=${msgid//\"\"/} msgid=${msgid//\"\"/}
...@@ -192,7 +202,10 @@ EOF ...@@ -192,7 +202,10 @@ EOF
echo \["$msgid"\]="$msgid" >> "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" echo \["$msgid"\]="$msgid" >> "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE"
fi fi
fi fi
if [[ -z $msgid ]] && [[ -z $msgstr ]] ; then done
done < "$po_file"
IFS="$orig_IFS"
echo ")" >> "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" echo ")" >> "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE"
sed -i 's/+_+/\n/g' "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" sed -i 's/+_+/\n/g' "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE"
sed -i 's/#_#/\*/g' "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" sed -i 's/#_#/\*/g' "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE"
...@@ -200,11 +213,6 @@ EOF ...@@ -200,11 +213,6 @@ EOF
if [[ $LANGUAGE == "en" ]] ; then if [[ $LANGUAGE == "en" ]] ; then
sed -i 's/msgid //g' "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" sed -i 's/msgid //g' "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE"
fi fi
return 0
fi
done
done < "$po_file"
} }
export -f create_translations export -f create_translations
......
...@@ -172,10 +172,9 @@ unset translations ...@@ -172,10 +172,9 @@ unset translations
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" source "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE"
if [[ "$TRANSLATIONS_VER" != "$scripts_install_ver" ]] ; then if [[ $TRANSLATIONS_VER != "$scripts_install_ver" ]] ; then
try_remove_dir "${PORT_SCRIPTS_PATH}/translations" try_remove_dir "${PORT_SCRIPTS_PATH}/translations"
create_translations create_translations
unset translations
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" source "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE"
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment