From 0b963639b735b5849b613f0aa7be1db111eb12e6 Mon Sep 17 00:00:00 2001 From: Htylol Date: Mon, 7 Oct 2024 07:20:05 +0500 Subject: [PATCH] Update display time function --- data_from_portwine/locales/PortProton.pot | 26 ++++++++++++- .../locales/es/LC_MESSAGES/PortProton.po | 26 ++++++++++++- .../locales/ru/LC_MESSAGES/PortProton.po | 28 +++++++++++++- data_from_portwine/scripts/functions_helper | 38 +++++++++++++++++-- data_from_portwine/scripts/start.sh | 2 + 5 files changed, 112 insertions(+), 8 deletions(-) diff --git a/data_from_portwine/locales/PortProton.pot b/data_from_portwine/locales/PortProton.pot index 7679b26f..ab6490ff 100644 --- a/data_from_portwine/locales/PortProton.pot +++ b/data_from_portwine/locales/PortProton.pot @@ -7,7 +7,7 @@ msgid "" msgstr "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" - "POT-Creation-Date: 2024-10-07 05:41+0500\n" + "POT-Creation-Date: 2024-10-07 07:15+0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -224,6 +224,30 @@ msgstr "" msgid "Downloading" msgstr "" +msgid "day" +msgstr "" + +msgid "days" +msgstr "" + +msgid "hour" +msgstr "" + +msgid "and" +msgstr "" + +msgid "hours" +msgstr "" + +msgid "minute" +msgstr "" + +msgid "minutes" +msgstr "" + +msgid "Time spent" +msgstr "" + msgid "Do you really want to reinstall PortProton?\\nFor this, an internet " "connection will be required." msgstr "" diff --git a/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po b/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po index 1a566e50..4c4fbfaf 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-10-07 05:31+0500\n" +"POT-Creation-Date: 2024-10-07 07:15+0500\n" "PO-Revision-Date: 2024-09-19 23:35+0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -247,6 +247,30 @@ msgstr "" msgid "Downloading" msgstr "Descargando" +msgid "day" +msgstr "" + +msgid "days" +msgstr "" + +msgid "hour" +msgstr "" + +msgid "and" +msgstr "" + +msgid "hours" +msgstr "" + +msgid "minute" +msgstr "" + +msgid "minutes" +msgstr "" + +msgid "Time spent" +msgstr "" + msgid "" "Do you really want to reinstall PortProton?\\nFor this, an internet " "connection will be required." diff --git a/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po b/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po index 4c3bc7a4..09ac0ae7 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-10-07 05:31+0500\n" -"PO-Revision-Date: 2024-10-07 05:41+0500\n" +"POT-Creation-Date: 2024-10-07 07:15+0500\n" +"PO-Revision-Date: 2024-10-07 07:16+0500\n" "Last-Translator: \n" "Language-Team: \n" "Language: ru_RU\n" @@ -248,6 +248,30 @@ msgstr "" msgid "Downloading" msgstr "Загружается" +msgid "day" +msgstr "день" + +msgid "days" +msgstr "дней" + +msgid "hour" +msgstr "час" + +msgid "and" +msgstr "и" + +msgid "hours" +msgstr "часов" + +msgid "minute" +msgstr "минута" + +msgid "minutes" +msgstr "минут" + +msgid "Time spent" +msgstr "Проведено времени" + msgid "" "Do you really want to reinstall PortProton?\\nFor this, an internet " "connection will be required." diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper index c67060cf..b3bf2783 100755 --- a/data_from_portwine/scripts/functions_helper +++ b/data_from_portwine/scripts/functions_helper @@ -820,15 +820,45 @@ seconds_to_time () { local minutes=$((seconds / 60)) local hours=$((minutes / 60)) local days=$((hours / 24)) - local remaining_minutes=$((minutes % 60)) local remaining_hours=$((hours % 24)) - if [[ "$LANGUAGE" == ru ]] ; then - echo "\n$days дней, $remaining_hours часов и $remaining_minutes минут" + if [[ $days =~ ^0$ ]] ; then + local remaining_days= + elif [[ $days =~ ^1$ ]] ; then + local remaining_days="$days ${translations[day]}, " + elif [[ $days =~ ^([2-9]1|[1-9][0-9]+1)$ ]] && [[ $LANGUAGE = ru ]] ; then + local remaining_days="$days ${translations[day]}, " + elif [[ $days =~ ^(2|3|4|[2-9]2|[2-9]3|[2-9]4|[1-9][0-9]+2|[1-9][0-9]+3|[1-9][0-9]+4)$ ]] \ + && [[ $LANGUAGE = ru ]] ; then + local remaining_days="$days дня, " else - echo "\n$days days, $remaining_hours hours and $remaining_minutes minutes" + local remaining_days="$days ${translations[days]}, " fi + + if [[ $remaining_hours =~ ^0$ ]] ; then + local remaining_hours= + elif [[ $remaining_hours =~ ^1$ ]] ; then + local remaining_hours="$hours ${translations[hour]} ${translations[and]} " + elif [[ $remaining_hours =~ ^(2|3|4|22|23|24)$ ]] && [[ $LANGUAGE = ru ]] ; then + local remaining_hours="$hours часа ${translations[and]} " + elif [[ $remaining_hours =~ ^21$ ]] && [[ $LANGUAGE = ru ]] ; then + local remaining_hours="$hours час ${translations[and]} " + else + local remaining_hours="$hours ${translations[hours]} ${translations[and]} " + fi + + if [[ $remaining_minutes =~ ^1$ ]] ; then + local remaining_minutes="$remaining_minutes ${translations[minute]}" + elif [[ $remaining_minutes =~ ^[2-5]1$ ]] && [[ $LANGUAGE = ru ]] ; then + local remaining_minutes="$remaining_minutes ${translations[minute]}" + elif [[ $remaining_minutes =~ ^(2|3|4|[2-5]2|[2-5]3|[2-5]4)$ ]] && [[ $LANGUAGE = ru ]] ; then + local remaining_minutes="$remaining_minutes минуты" + else + local remaining_minutes="$remaining_minutes ${translations[minutes]}" + fi + + echo "\n${translations[Time spent]}: $remaining_days$remaining_hours$remaining_minutes" } combobox_fix () { diff --git a/data_from_portwine/scripts/start.sh b/data_from_portwine/scripts/start.sh index 7af73a27..6110b13b 100755 --- a/data_from_portwine/scripts/start.sh +++ b/data_from_portwine/scripts/start.sh @@ -506,6 +506,8 @@ if [[ -f "${portwine_exe}" ]] ; then else PW_COMMENT_DB="${translations[Launching]} $(print_wrapped "${PORTWINE_DB}" "50")$(seconds_to_time $TIME_CURRENT)" fi + else + PW_COMMENT_DB="$PW_COMMENT_DB$(seconds_to_time $TIME_CURRENT)" fi export KEY_START="$RANDOM"