Commit d44835c5 authored by Vladislav's avatar Vladislav

Added eval_translations

parent ced81385
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
msgid "" msgid ""
msgstr "Project-Id-Version: PACKAGE VERSION\n" msgstr "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-19 00:55+0500\n" "POT-Creation-Date: 2024-09-19 21:02+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -1552,7 +1552,7 @@ msgid "scripts" ...@@ -1552,7 +1552,7 @@ msgid "scripts"
msgstr "" msgstr ""
#, sh-format #, sh-format
msgid "Copyright © $DATE Castro-Fidel (linux-gaming.ru)" msgid "Copyright © ${DATE} Castro-Fidel (linux-gaming.ru)"
msgstr "" msgstr ""
msgid "This program comes with absolutely no warranty.\n" msgid "This program comes with absolutely no warranty.\n"
...@@ -1564,11 +1564,10 @@ msgid "Author: Casro-Fidel (Mikhail Tergoev)\n" ...@@ -1564,11 +1564,10 @@ msgid "Author: Casro-Fidel (Mikhail Tergoev)\n"
"Developer assistants and testers:" "Developer assistants and testers:"
msgstr "" msgstr ""
msgid "MIT License"
msgstr ""
#, sh-format #, sh-format
msgid "Copyright © $DATE Castro-Fidel (linux-gaming.ru)\n" msgid "MIT License\n"
"\n"
"Copyright © ${DATE} Castro-Fidel (linux-gaming.ru)\n"
"\n" "\n"
"Permission is hereby granted, free of charge, to any person " "Permission is hereby granted, free of charge, to any person "
"obtaining a copy\n" "obtaining a copy\n"
......
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-19 00:55+0500\n" "POT-Creation-Date: 2024-09-19 20:52+0500\n"
"PO-Revision-Date: 2024-09-15 15:29+0500\n" "PO-Revision-Date: 2024-09-15 15:29+0500\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
...@@ -2011,7 +2011,7 @@ msgid "scripts" ...@@ -2011,7 +2011,7 @@ msgid "scripts"
msgstr "Actualizar scripts:" msgstr "Actualizar scripts:"
#, sh-format #, sh-format
msgid "Copyright © $DATE Castro-Fidel (linux-gaming.ru)" msgid "Copyright © ${DATE} Castro-Fidel (linux-gaming.ru)"
msgstr "" msgstr ""
msgid "" msgid ""
...@@ -2025,12 +2025,11 @@ msgid "" ...@@ -2025,12 +2025,11 @@ msgid ""
"Developer assistants and testers:" "Developer assistants and testers:"
msgstr "" msgstr ""
msgid "MIT License"
msgstr ""
#, sh-format #, sh-format
msgid "" msgid ""
"Copyright © $DATE Castro-Fidel (linux-gaming.ru)\n" "MIT License\n"
"\n"
"Copyright © ${DATE} Castro-Fidel (linux-gaming.ru)\n"
"\n" "\n"
"Permission is hereby granted, free of charge, to any person obtaining a " "Permission is hereby granted, free of charge, to any person obtaining a "
"copy\n" "copy\n"
......
...@@ -7,8 +7,8 @@ msgid "" ...@@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-19 00:55+0500\n" "POT-Creation-Date: 2024-09-19 20:52+0500\n"
"PO-Revision-Date: 2024-09-18 22:48+0500\n" "PO-Revision-Date: 2024-09-19 21:03+0500\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"Language: ru_RU\n" "Language: ru_RU\n"
...@@ -1976,9 +1976,9 @@ msgstr "СОХРАНИТЬ" ...@@ -1976,9 +1976,9 @@ msgstr "СОХРАНИТЬ"
msgid "scripts" msgid "scripts"
msgstr "версия" msgstr "версия"
#, fuzzy, sh-format #, sh-format
msgid "Copyright © $DATE Castro-Fidel (linux-gaming.ru)" msgid "Copyright © ${DATE} Castro-Fidel (linux-gaming.ru)"
msgstr "Авторские права © $DATE Castro-Fidel (linux-gaming.ru)" msgstr "Авторские права © ${DATE} Castro-Fidel (linux-gaming.ru)"
msgid "" msgid ""
"This program comes with absolutely no warranty.\n" "This program comes with absolutely no warranty.\n"
...@@ -1996,12 +1996,11 @@ msgstr "" ...@@ -1996,12 +1996,11 @@ msgstr ""
"\n" "\n"
"Помощники разработчика и тестировщики:" "Помощники разработчика и тестировщики:"
msgid "MIT License"
msgstr "Лицензия Массачусетского технологического института (MIT License)"
#, sh-format #, sh-format
msgid "" msgid ""
"Copyright © $DATE Castro-Fidel (linux-gaming.ru)\n" "MIT License\n"
"\n"
"Copyright © ${DATE} Castro-Fidel (linux-gaming.ru)\n"
"\n" "\n"
"Permission is hereby granted, free of charge, to any person obtaining a " "Permission is hereby granted, free of charge, to any person obtaining a "
"copy\n" "copy\n"
...@@ -2027,7 +2026,9 @@ msgid "" ...@@ -2027,7 +2026,9 @@ msgid ""
"THE\n" "THE\n"
"SOFTWARE." "SOFTWARE."
msgstr "" msgstr ""
"Авторские права © $DATE Castro-Fidel (linux-gaming.ru)\n" "Лицензия Массачусетского технологического института (MIT License)\n"
"\n"
"Авторские права © ${DATE} Castro-Fidel (linux-gaming.ru)\n"
"\n" "\n"
"Настоящим предоставляется бесплатное разрешение любому лицу, получившему " "Настоящим предоставляется бесплатное разрешение любому лицу, получившему "
"копию данного\n" "копию данного\n"
...@@ -2136,6 +2137,9 @@ msgstr "ПРИСОЕДЕНИТЬСЯ" ...@@ -2136,6 +2137,9 @@ msgstr "ПРИСОЕДЕНИТЬСЯ"
msgid "THIRD PARTY LIBRARIES" msgid "THIRD PARTY LIBRARIES"
msgstr "БИБЛИОТЕКИ" msgstr "БИБЛИОТЕКИ"
#~ msgid "MIT License"
#~ msgstr "Лицензия Массачусетского технологического института (MIT License)"
#~ msgid "(Can be selected and copied)" #~ msgid "(Can be selected and copied)"
#~ msgstr "(можно выделить и скопировать)" #~ msgstr "(можно выделить и скопировать)"
......
...@@ -97,12 +97,15 @@ export -f change_locale ...@@ -97,12 +97,15 @@ export -f change_locale
generate_pot () { generate_pot () {
sed 's/{translations\[/(gettext \"/g' functions_helper > functions_helper_tmp sed 's/{translations\[/(gettext \"/g' functions_helper > functions_helper_tmp
sed -i 's/]}/")/g' functions_helper_tmp sed -i 's/]}/")/g' functions_helper_tmp
sed -i 's/eval_translations/gettext/g' functions_helper_tmp
sed 's/{translations\[/(gettext \"/g' start.sh > start.sh_tmp sed 's/{translations\[/(gettext \"/g' start.sh > start.sh_tmp
sed -i 's/]}/")/g' start.sh_tmp sed -i 's/]}/")/g' start.sh_tmp
sed -i 's/eval_translations/gettext/g' start.sh_tmp
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
sed -i 's/eval_translations/gettext/g' setup.sh_tmp
#Когда присходит предупреждение: синтаксис $"..." запрещен по соображениям безопасности; используйте eval_gettext #Когда присходит предупреждение: синтаксис $"..." запрещен по соображениям безопасности; используйте eval_gettext
#и ругается на строку в которой нет перевода, можно использовать sed -i '//d' и убрать эту строку #и ругается на строку в которой нет перевода, можно использовать sed -i '//d' и убрать эту строку
...@@ -138,6 +141,15 @@ generate_pot () { ...@@ -138,6 +141,15 @@ generate_pot () {
} }
export -f generate_pot export -f generate_pot
eval_translations () {
# Для того чтобы раскрывать переменную уже после создания массива
# Вместо {translations[\$TEST text]} нужно (eval_translations "\${TEST} text" "TEST=test") в переводе переменная должна быть в {}
# В остальных случаях можно использовать {translations[\$TEST text]} ,но переменную нужно обьявлять до создания массива
# до source "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" или можно использовать команды {translations[\$(cat file.txt) text]}
# но тогда выполнение команды будет происходить во время создания массива всегда, а не там где это требуется
echo "${translations[$1]//\$*"}"/${2//*=/}}"
}
create_translations () { create_translations () {
if [[ ! -d "${PORT_SCRIPTS_PATH}/translations" ]] ; then if [[ ! -d "${PORT_SCRIPTS_PATH}/translations" ]] ; then
create_new_dir "${PORT_SCRIPTS_PATH}/translations" create_new_dir "${PORT_SCRIPTS_PATH}/translations"
...@@ -201,6 +213,9 @@ EOF ...@@ -201,6 +213,9 @@ EOF
fi fi
if [[ $msgid =~ "\$" ]] ; then if [[ $msgid =~ "\$" ]] ; then
msgid=${msgid//"\$"/\\$} msgid=${msgid//"\$"/\\$}
if [[ $msgstr =~ "\${" ]] ; then
msgstr=${msgstr//"\$"/\\$}
fi
fi fi
echo \["$msgid"\]="$msgstr" >> "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" echo \["$msgid"\]="$msgstr" >> "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE"
fi fi
...@@ -4700,7 +4715,8 @@ gui_gamescope () { ...@@ -4700,7 +4715,8 @@ gui_gamescope () {
done done
else else
if check_flatpak ; then if check_flatpak ; then
GAMESCOPE_NEED_INSTALL="${translations[<b>Gamescope is not detected on the system, to install it, run the command in the terminal:\\nflatpak install -y runtime/org.freedesktop.Platform.VulkanLayer.gamescope/x86_64/\${GAMESCOPE_VERSION}\\n(Can be selected and copied)</b>]}" GAMESCOPE_VERSION="$(grep 'VERSION_ID=' /etc/os-release)"
GAMESCOPE_NEED_INSTALL=$(eval_translations "<b>Gamescope is not detected on the system, to install it, run the command in the terminal:\\nflatpak install -y runtime/org.freedesktop.Platform.VulkanLayer.gamescope/x86_64/\${GAMESCOPE_VERSION}\\n(Can be selected and copied)</b>" "GAMESCOPE_VERSION=${GAMESCOPE_VERSION//VERSION_ID=/}")
YAD_TEXT_SELECTION="--selectable-labels" YAD_TEXT_SELECTION="--selectable-labels"
else else
GAMESCOPE_NEED_INSTALL="${translations[<b>Gamescope is not detected on the system, please contact the manufacturer of your distribution\\nor search the Internet for information on how to install gamescope on your system.</b>]}" GAMESCOPE_NEED_INSTALL="${translations[<b>Gamescope is not detected on the system, please contact the manufacturer of your distribution\\nor search the Internet for information on how to install gamescope on your system.</b>]}"
...@@ -5844,7 +5860,7 @@ gui_credits () { ...@@ -5844,7 +5860,7 @@ gui_credits () {
--text-align=center --text="PortProton v. ${install_ver} --text-align=center --text="PortProton v. ${install_ver}
${translations[scripts]} v. ${scripts_install_ver}" --text-info <<< "https://linux-gaming.ru ${translations[scripts]} v. ${scripts_install_ver}" --text-info <<< "https://linux-gaming.ru
${translations[Copyright © \$DATE Castro-Fidel (linux-gaming.ru)]} $(eval_translations "Copyright © \${DATE} Castro-Fidel (linux-gaming.ru)" "DATE=$(date +%Y)")
${translations[This program comes with absolutely no warranty. ${translations[This program comes with absolutely no warranty.
See the License for details.]}" 2>/dev/null & See the License for details.]}" 2>/dev/null &
...@@ -5855,9 +5871,9 @@ See the License for details.]}" 2>/dev/null & ...@@ -5855,9 +5871,9 @@ See the License for details.]}" 2>/dev/null &
Developer assistants and testers:]} Developer assistants and testers:]}
$(credits_devel)" 2>/dev/null & $(credits_devel)" 2>/dev/null &
"${pw_yad}" --plug="${KEY_CREDITS}" --tabnum=3 --text-info --scroll <<< "${translations[MIT License]} "${pw_yad}" --plug="${KEY_CREDITS}" --tabnum=3 --text-info --scroll <<< "$(eval_translations "MIT License
${translations[Copyright © \$DATE Castro-Fidel (linux-gaming.ru) Copyright © \${DATE} Castro-Fidel (linux-gaming.ru)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the \"Software\"), to deal of this software and associated documentation files (the \"Software\"), to deal
...@@ -5875,7 +5891,7 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ...@@ -5875,7 +5891,7 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.]}" 2>/dev/null & SOFTWARE." "DATE=$(date +%Y)")" 2>/dev/null &
"${pw_yad}" --plug="${KEY_CREDITS}" --tabnum=4 \ "${pw_yad}" --plug="${KEY_CREDITS}" --tabnum=4 \
--text-info --show-uri --scroll \ --text-info --show-uri --scroll \
......
...@@ -168,13 +168,6 @@ if [[ ! -f "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" ]] ; then ...@@ -168,13 +168,6 @@ if [[ ! -f "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" ]] ; then
create_translations create_translations
fi fi
# для переводов нужно экспортировать переменные заранее
# так же можно использовать сразу команду или функцию
# по типу $(...), но тоже заранее функцию нужно экспортировать
DATE=$(date +%Y)
GAMESCOPE_VERSION="$(grep 'VERSION_ID=' /etc/os-release)"
GAMESCOPE_VERSION="${GAMESCOPE_VERSION//VERSION_ID=/}"
unset translations unset translations
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" source "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE"
......
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