From ae69564ff59f729e31e7ac123bd606a43404c98d Mon Sep 17 00:00:00 2001 From: Htylol Date: Wed, 18 Sep 2024 23:04:31 +0500 Subject: [PATCH] Added the ability to expand variables in translations --- data_from_portwine/locales/PortProton.pot | 19 ++++---- .../locales/es/LC_MESSAGES/PortProton.po | 20 +++++---- .../locales/ru/LC_MESSAGES/PortProton.po | 45 +++++++++++-------- data_from_portwine/scripts/functions_helper | 21 +++++---- data_from_portwine/scripts/start.sh | 5 +++ 5 files changed, 63 insertions(+), 47 deletions(-) diff --git a/data_from_portwine/locales/PortProton.pot b/data_from_portwine/locales/PortProton.pot index 6c6a82b..8140073 100644 --- a/data_from_portwine/locales/PortProton.pot +++ b/data_from_portwine/locales/PortProton.pot @@ -7,13 +7,13 @@ msgid "" msgstr "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" - "POT-Creation-Date: 2024-09-18 01:14+0500\n" + "POT-Creation-Date: 2024-09-18 22:54+0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" - "Content-Type: text/plain; charset=CHARSET\n" + "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" msgid "A running PortProton session was detected.\\nDo you want to end the " @@ -1245,12 +1245,11 @@ msgstr "" msgid "Change settings gamescope for" msgstr "" -msgid "Gamescope is not detected on the system, to install it, run the " +#, sh-format +msgid "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/" -msgstr "" - -msgid "(Can be selected and copied)" + "${GAMESCOPE_VERSION}\\n(Can be selected and copied)" msgstr "" msgid "Gamescope is not detected on the system, please contact the " @@ -1552,7 +1551,8 @@ msgstr "" msgid "scripts" msgstr "" -msgid "Copyright" +#, sh-format +msgid "Copyright © $DATE Castro-Fidel (linux-gaming.ru)" msgstr "" msgid "This program comes with absolutely no warranty.\n" @@ -1567,7 +1567,10 @@ msgstr "" msgid "MIT License" msgstr "" -msgid "Permission is hereby granted, free of charge, to any person " +#, sh-format +msgid "Copyright © $DATE Castro-Fidel (linux-gaming.ru)\n" + "\n" + "Permission is hereby granted, free of charge, to any person " "obtaining a copy\n" "of this software and associated documentation files (the " "\"Software\"), to deal\n" diff --git a/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po b/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po index 0630f7f..36399bc 100644 --- a/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po +++ b/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-18 01:14+0500\n" +"POT-Creation-Date: 2024-09-18 22:44+0500\n" "PO-Revision-Date: 2024-09-15 15:29+0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -1627,20 +1627,18 @@ msgstr "" msgid "Change settings gamescope for" msgstr "Cambiar ajustes gamescope para" -#, fuzzy +#, fuzzy, sh-format msgid "" -"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 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)" msgstr "" " Gamescope no se detecta en el sistema, para instalarlo, ejecute el " "comando en el terminal:\\n flatpak install -y runtime/org.freedesktop." "Platform.VulkanLayer.gamescope/x86_64/${GAMESCOPE_VERSION}\\n (Se puede " "seleccionar y copiar)." -msgid "(Can be selected and copied)" -msgstr "" - #, fuzzy msgid "" "Gamescope is not detected on the system, please contact the manufacturer " @@ -2012,7 +2010,8 @@ msgstr "AHORRAR" msgid "scripts" msgstr "Actualizar scripts:" -msgid "Copyright" +#, sh-format +msgid "Copyright © $DATE Castro-Fidel (linux-gaming.ru)" msgstr "" msgid "" @@ -2029,7 +2028,10 @@ msgstr "" msgid "MIT License" msgstr "" +#, sh-format msgid "" +"Copyright © $DATE Castro-Fidel (linux-gaming.ru)\n" +"\n" "Permission is hereby granted, free of charge, to any person obtaining a " "copy\n" "of this software and associated documentation files (the \"Software\"), to " diff --git a/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po b/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po index 2ed5d12..25fef0f 100644 --- a/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po +++ b/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-18 01:14+0500\n" -"PO-Revision-Date: 2024-09-17 20:12+0500\n" +"POT-Creation-Date: 2024-09-18 22:44+0500\n" +"PO-Revision-Date: 2024-09-18 22:48+0500\n" "Last-Translator: \n" "Language-Team: \n" "Language: ru_RU\n" @@ -1176,7 +1176,6 @@ msgstr "" msgid "Show temperature in Fahrenheit" msgstr "Показывать температуру в градусах Фаренгейта" -#, fuzzy msgid "" "Show if GPU is throttling based on Power, current, temp or other (Only shows " "if throttling is currently happening). Currently disabled by default for " @@ -1377,7 +1376,6 @@ msgstr "" "Включение данной опции помогает исправить зависание или вылетание в " "некоторых играх при сворачивании окна (Glide)" -#, fuzzy msgid "" "dgVoodoo2 settings\\nNOTE: To display help for each item, simply " "hover over the text" @@ -1598,27 +1596,25 @@ msgstr "" msgid "Change settings gamescope for" msgstr "Изменить настройки Gamescope для" -#, fuzzy +#, sh-format msgid "" -"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 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)" msgstr "" -"Gamescope не найден в системе, для его установки выполните команду в " -"терминале:\\n flatpak install -y runtime/org.freedesktop.Platform." -"VulkanLayer.gamescope/x86_64/" +"Gamescope не найден в системе, для его установки выполните команду в " +"терминале:\\nflatpak install -y runtime/org.freedesktop.Platform.VulkanLayer." +"gamescope/x86_64/${GAMESCOPE_VERSION}\\n(Данный текст можно выделить и " +"скопировать)" -msgid "(Can be selected and copied)" -msgstr "(можно выделить и скопировать)" - -#, fuzzy msgid "" "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." msgstr "" "Gamescope не найден в системе, обратитесь к производителю вашего " -"дистрибутива\\n или поищите в Интернете информацию о том, как установить " +"дистрибутива\\nили поищите в Интернете информацию о том, как установить " "gamescope в вашей системе" msgid "Show resolution" @@ -1648,7 +1644,6 @@ msgstr "Ограничение частоты кадров (кадров в се msgid "Mesa vulkan WSI" msgstr "Режим работы окна" -#, fuzzy msgid "" "Overrides the WSI present mode:\n" "fifo - First in, first out. Limits the frame rate + no tearing. (VSync)\n" @@ -1981,8 +1976,9 @@ msgstr "СОХРАНИТЬ" msgid "scripts" msgstr "версия" -msgid "Copyright" -msgstr "Авторские права" +#, sh-format +msgid "Copyright © $DATE Castro-Fidel (linux-gaming.ru)" +msgstr "Авторские права © $DATE Castro-Fidel (linux-gaming.ru)" msgid "" "This program comes with absolutely no warranty.\n" @@ -2003,7 +1999,10 @@ msgstr "" msgid "MIT License" msgstr "Лицензия Массачусетского технологического института (MIT License)" +#, sh-format msgid "" +"Copyright © $DATE Castro-Fidel (linux-gaming.ru)\n" +"\n" "Permission is hereby granted, free of charge, to any person obtaining a " "copy\n" "of this software and associated documentation files (the \"Software\"), to " @@ -2028,6 +2027,8 @@ msgid "" "THE\n" "SOFTWARE." msgstr "" +"Авторские права © $DATE Castro-Fidel (linux-gaming.ru)\n" +"\n" "Настоящим предоставляется бесплатное разрешение любому лицу, получившему " "копию данного\n" "программного обеспечения и связанных с ним файлов документации (Программное\n" @@ -2135,6 +2136,12 @@ msgstr "ПРИСОЕДЕНИТЬСЯ" msgid "THIRD PARTY LIBRARIES" msgstr "БИБЛИОТЕКИ" +#~ msgid "(Can be selected and copied)" +#~ msgstr "(можно выделить и скопировать)" + +#~ msgid "Copyright" +#~ msgstr "Авторские права" + #, sh-format #~ msgid "" #~ "PortProton v. ${install_ver}\n" diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper index d112f30..cc124b0 100755 --- a/data_from_portwine/scripts/functions_helper +++ b/data_from_portwine/scripts/functions_helper @@ -196,11 +196,13 @@ EOF msgid=${msgid//#*/} msgid=${msgid//"*"/#_#} if [[ $msgid != "" ]] ; then - if [[ -n $msgstr ]] ; then - echo \["$msgid"\]="$msgstr" >> "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" - else - echo \["$msgid"\]="$msgid" >> "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" + if [[ -z $msgstr ]] ; then + msgstr="$msgid" fi + if [[ $msgid =~ "\$" ]] ; then + msgid=${msgid//"\$"/\\$} + fi + echo \["$msgid"\]="$msgstr" >> "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" fi done done < "$po_file" @@ -4698,9 +4700,7 @@ gui_gamescope () { done else if check_flatpak ; then - GAMESCOPE_VERSION="$(grep 'VERSION_ID=' /etc/os-release)" - GAMESCOPE_VERSION="${GAMESCOPE_VERSION//VERSION_ID=/}" - GAMESCOPE_NEED_INSTALL="${translations[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${translations[(Can be selected and copied)]}" + GAMESCOPE_NEED_INSTALL="${translations[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)]}" YAD_TEXT_SELECTION="--selectable-labels" else GAMESCOPE_NEED_INSTALL="${translations[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.]}" @@ -5836,7 +5836,6 @@ gui_credits () { # grep ';subscription;' stat-subscriptions.csv | awk -F';' '{print $1}' | sort -u | sed "s/\"//g" > thanks ######################################################################## KEY_CREDITS=$RANDOM - DATE=$(date +'%Y') # shellcheck source=/dev/null source "${PORT_WINE_PATH}/data/scripts/thanks" @@ -5845,7 +5844,7 @@ gui_credits () { --text-align=center --text="PortProton v. ${install_ver} ${translations[scripts]} v. ${scripts_install_ver}" --text-info <<< "https://linux-gaming.ru -${translations[Copyright]} © $DATE Castro-Fidel (linux-gaming.ru) +${translations[Copyright © \$DATE Castro-Fidel (linux-gaming.ru)]} ${translations[This program comes with absolutely no warranty. See the License for details.]}" 2>/dev/null & @@ -5858,9 +5857,9 @@ $(credits_devel)" 2>/dev/null & "${pw_yad}" --plug="${KEY_CREDITS}" --tabnum=3 --text-info --scroll <<< "${translations[MIT License]} -${translations[Copyright]} © $DATE Castro-Fidel (linux-gaming.ru) +${translations[Copyright © \$DATE Castro-Fidel (linux-gaming.ru) -${translations[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 in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell diff --git a/data_from_portwine/scripts/start.sh b/data_from_portwine/scripts/start.sh index 951a3be..9348618 100755 --- a/data_from_portwine/scripts/start.sh +++ b/data_from_portwine/scripts/start.sh @@ -168,6 +168,11 @@ if [[ ! -f "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE" ]] ; then create_translations fi +# для переводов нужно экспортировать переменные заранее +DATE=$(date +'%Y') +GAMESCOPE_VERSION="$(grep 'VERSION_ID=' /etc/os-release)" +GAMESCOPE_VERSION="${GAMESCOPE_VERSION//VERSION_ID=/}" + unset translations # shellcheck source=/dev/null source "${PORT_SCRIPTS_PATH}/translations/$LANGUAGE"