From 63c22343e31dc1a7b5a6348e65c0bd4a643d6641 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Thu, 9 Feb 2023 15:59:18 +0600 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B7=D0=BE=D0=BD=20=D0=B8=20=D1=80=D0=B5=D0=B3=D0=B8?= =?UTF-8?q?=D0=BE=D0=BD=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/CMakeLists.txt | 4 +- source/ubl-settings-datetime.cc | 140 +++++++++++++++++--------------- source/ubl-settings-datetime.h | 18 +++- ubl-settings-datetime_ru.po | 49 ++++++++--- 4 files changed, 133 insertions(+), 78 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 5289d63..13840d1 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -9,8 +9,8 @@ link_directories(${GTK_LIBRARY_DIRS}) add_definitions(${GTK_CFLAGS_OTHER}) find_package(ICU REQUIRED COMPONENTS uc dt in io) -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a -g") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -g") +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always") set(SOURCE_FILES main.cc diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index f64cccc..5401ac7 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -114,39 +114,39 @@ void MainWindow::settings(){ int MainWindow::check_root(){ if (geteuid()!=0){ - lblMessageSudo->set_text(gettext("The program must be run with \nsuperuser privileges!")); + lblMessageSudo->set_text(_("The program must be run with \nsuperuser privileges!")); mess_sudo->show(); return 1; } return 0; } void MainWindow::lacalization(){ - txtDate->set_tooltip_text(gettext("Date of\nFormat: DD.MM.YYYY")); - lblSynchronizebChkGLob->set_text(gettext("Synchronize via NTP")); - cbDhcp->append(gettext("By default")); - cbDhcp->append(gettext("DHCP")); - cbDhcp->append(gettext("Manually")); - lblDateTimeSetting->set_text(gettext("Local Configuration")); - lblHead->set_text(gettext("Settings the date and time")); - lblTime->set_text(gettext("Time")); - lblData->set_text(gettext("Date")); - lblTimeZone->set_text(gettext("Time zone")); - lblReg->set_text(gettext("Region")); - lblZone->set_text(gettext("Zone")); - lblRegGlob->set_text(gettext("Region")); - lblZone1Glob->set_text(gettext("Zone")); - lblTimeZoneGlob->set_text(gettext("Time zone")); - lblSynchronizeBtn->set_text(gettext("Sync by")); - lblDateTimeSettingGlob->set_text(gettext("Global customization")); - this->set_title(gettext("ubl-settings-datetime")); - windowsNnpClose->set_title(gettext("Warning!")); - mess_sudo->set_title(gettext("Warning!")); - mess_dchp->set_title(gettext("Warning!")); - lblTimeBios->set_text(gettext("Synchronize hardware time")); - lblBanerStopNtp->set_text(gettext("Active service detected\nAutomatic time and date synchronization service detected")); - lblNtpStop->set_text(gettext("Stop the synchronization service")); - lblNtpClose->set_text(gettext("Close")); - //_lblSynchronizebChk->set_text(gettext("Synchronize via NTP")); + txtDate->set_tooltip_text(_("Date of\nFormat: DD.MM.YYYY")); + lblSynchronizebChkGLob->set_text(_("Synchronize via NTP")); + cbDhcp->append(_("By default")); + cbDhcp->append(_("DHCP")); + cbDhcp->append(_("Manually")); + lblDateTimeSetting->set_text(_("Local Configuration")); + lblHead->set_text(_("Settings the date and time")); + lblTime->set_text(_("Time")); + lblData->set_text(_("Date")); + lblTimeZone->set_text(_("Time zone")); + lblReg->set_text(_("Region")); + lblZone->set_text(_("Zone")); + lblRegGlob->set_text(_("Region")); + lblZone1Glob->set_text(_("Zone")); + lblTimeZoneGlob->set_text(_("Time zone")); + lblSynchronizeBtn->set_text(_("Sync by")); + lblDateTimeSettingGlob->set_text(_("Global customization")); + this->set_title(_("ubl-settings-datetime")); + windowsNnpClose->set_title(_("Warning!")); + mess_sudo->set_title(_("Warning!")); + mess_dchp->set_title(_("Warning!")); + lblTimeBios->set_text(_("Synchronize hardware time")); + lblBanerStopNtp->set_text(_("Active service detected\nAutomatic time and date synchronization service detected")); + lblNtpStop->set_text(_("Stop the synchronization service")); + lblNtpClose->set_text(_("Close")); + //_lblSynchronizebChk->set_text(_("Synchronize via NTP")); } void MainWindow::flag_block_gui(){ @@ -320,7 +320,7 @@ void MainWindow::gui_mess_close(){ bool MainWindow::focus_ntp(GdkEventFocus* event){ if (event!=NULL){} if (txtNtpServer->get_text()=="" || txtNtpServer->get_text()==" "){ - lblMessage->set_text(gettext("Enter DHCP!")); + lblMessage->set_text(_("Enter DHCP!")); mess_dchp->show(); } else{ @@ -335,7 +335,6 @@ bool MainWindow::focus_ntp(GdkEventFocus* event){ void MainWindow::event_entry_cbDhcp(){ Glib::ustring str_dhcp = cbDhcp->get_active_text(); int activ_index = cbDhcp->get_active_row_number(); - cout << activ_index << endl; if (str_dhcp.length()!=0){ if (activ_index==0){ string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default"; @@ -443,7 +442,7 @@ void MainWindow::enry_dhcp_mess(){ } else{ if (str_dhcp==""){ - lblMessage->set_text(gettext("Enter DHCP!")); + lblMessage->set_text(_("Enter DHCP!")); mess_dchp->show(); } else if (str_dhcp=="(null)"){ @@ -480,6 +479,7 @@ void MainWindow::get_config(){ str_filling_zon = str_filling_zon.substr(0,str_filling_zon.find("\n")); string str_zone_check = ""; this->append_region_zone(str_filling_reg,str_filling_zon); + //this->append_region_zone("Africa","Abidjan"); } else { this->append_region_zone("Africa","Abidjan"); @@ -487,8 +487,9 @@ void MainWindow::get_config(){ } void MainWindow::enter_zone(){ - string reg_text = cbRegion->get_active_text(); - int activ_index = cbZone->get_active_row_number(); + int activ_index_reg = cbRegion->get_active_row_number(); + string reg_text=array_region[activ_index_reg]; + int activ_index = cbZone->get_active_row_number(); string zone_text = ""; if(!(reg_text.empty())){ int index=0; @@ -527,7 +528,8 @@ void MainWindow::parse_text_date(){ } void MainWindow::enter_zone_glob(){ - string reg_text = cbRegionGlob->get_active_text(); + int activ_index_reg = cbRegionGlob->get_active_row_number(); + string reg_text=array_region[activ_index_reg]; int activ_index = cbZoneGlob->get_active_row_number(); string zone_text=""; if(!(reg_text.empty())){ @@ -569,29 +571,34 @@ void MainWindow::set_ntp_toggle_glob(){ } void MainWindow::append_region_zone(string region, string zone){ + str_region=region; + str_region_glob=region; int index = 0; - string reg_local = ""; - for (auto &text : time_reg_map ) { - reg_local = text.first; - //reg_local = string(gettext(reg_local.c_str())); - cbRegion->append(reg_local); - cbRegionGlob->append(reg_local); - if (text.first == region){ - cbRegionGlob->set_active(index); - cbRegion->set_active(index); + Glib::ustring reg_local = ""; + for (const auto &text : array_region) { + reg_local = text; + reg_local = string(_(reg_local.c_str())); + cbRegion->append(Glib::ustring(reg_local)); + cbRegionGlob->append(Glib::ustring(reg_local)); + if (text == region){ + cbRegionGlob->set_active_text(reg_local); + cbRegion->set_active_text(reg_local); } index+=1; } + index = 0; string zone_mixing = ""; - string path_dir = ""; - for (const auto &_str_zone : time_reg_map.at(region)){ - path_dir=region+"/"+_str_zone; - zone_mixing = this->zone_file_read(path_dir) + string(gettext(_str_zone.c_str())); + string path_reg_zone = ""; + string zone_offest = ""; + path_reg_zone=region+"/"+zone; + zone_offest = this->zone_file_read(path_reg_zone) + _(zone.c_str()); + for (string &_str_zone : time_reg_map_local.at(region)){ cbZone->append(zone_mixing); cbZoneGlob->append(zone_mixing); + cout <<_str_zone << endl; if (_str_zone!=""){ - if (_str_zone == zone){ + if (zone_offest == _str_zone){ cbZone->set_active(index); cbZoneGlob->set_active(index); } @@ -621,34 +628,33 @@ string MainWindow::call(string cmd){ } void MainWindow::append_zone(){ + //int length_zone = time_reg_map.at(str_region).size(); cbZone->remove_all(); - Glib::ustring text = cbRegion->get_active_text(); + int index = cbRegion->get_active_row_number(); + string str_region = array_region[index]; string zone_mixing=""; string path_dir=""; - if(!(text.empty())){ - str_region = text; - for (const auto &_str_zone : time_reg_map.at(str_region)){ - path_dir=str_region+"/"+_str_zone; - zone_mixing = this->zone_file_read(path_dir) + string(gettext(_str_zone.c_str())); - cbZone->append(zone_mixing); + if(str_region.length()!=0){ + for (const auto &_str_zone : time_reg_map_local.at(str_region)){ + cbZone->append(Glib::ustring(_str_zone)); } } + cbZone->set_active(0); } void MainWindow::append_zone_glob(){ cbZoneGlob->remove_all(); - Glib::ustring text = cbRegionGlob->get_active_text(); + int index = cbRegionGlob->get_active_row_number(); + string str_region_glob = array_region[index]; string zone_mixing=""; string path_dir=""; - if(!(text.empty())){ - str_region_glob = text; - for (const auto &_str_zone : time_reg_map.at(str_region_glob)){ - path_dir=str_region+"/"+_str_zone; - zone_mixing = this->zone_file_read(path_dir) + string(gettext(_str_zone.c_str())); - cbZoneGlob->append(zone_mixing); + if(str_region_glob.length()!=0){ + for (const auto &_str_zone : time_reg_map_local.at(str_region_glob)){ + cbZoneGlob->append(Glib::ustring(_str_zone)); } } + cbZoneGlob->set_active(0); } void MainWindow::wrapper_update_time_date(){ string cmd = "pidof systemd-timesyncd ntpd chronyd"; @@ -726,7 +732,7 @@ void MainWindow::post_entry_data(){ } } else{ - lblMessage->set_text(gettext("Incorrect date format")); + lblMessage->set_text(_("Incorrect date format")); mess_dchp->show(); } } @@ -765,6 +771,8 @@ void MainWindow::update_calendar(){ void MainWindow::read_file(){ std::string line; + string key_zone_local = ""; + string path_reg_zone = ""; namespace fs = std::filesystem; for (const auto & entry : fs::directory_iterator("/usr/share/zoneinfo/")){ std::ifstream in(entry.path()); // окрываем файл для чтения @@ -777,6 +785,7 @@ void MainWindow::read_file(){ if (key_reg!="Etc"){ if (key_reg!="right"){ vector zone; + vector zone_local; //zone.push_back(""); for (const auto & entry_zone : fs::directory_iterator(path_dir)){ std::ifstream in1(entry_zone.path()); // окрываем файл для чтения @@ -784,13 +793,16 @@ void MainWindow::read_file(){ string key_zone = entry_zone.path().filename().string(); if (key_zone.length()!=0 || key_zone!=" "){ zone.push_back(key_zone); + path_reg_zone=key_reg + "/" + key_zone; + key_zone_local = this->zone_file_read(path_reg_zone) +_(key_zone.c_str()); + zone_local.push_back(key_zone_local); } } in1.close(); } - key_reg = string(key_reg); - time_reg_map.insert({key_reg, zone}); + time_reg_map.insert({key_reg, zone}); + time_reg_map_local.insert({key_reg, zone_local}); }}}} } } diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index 144e45b..c71a2ec 100644 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -121,7 +121,7 @@ class MainWindow : public Gtk::ApplicationWindow { Gtk::Entry *txtNtpServer; Gtk::Entry *txtDate; std::map > time_reg_map; - std::map time_reg_map_local; + std::map > time_reg_map_local; unsigned int year=0; unsigned int month=0; unsigned int day=0; @@ -133,7 +133,21 @@ class MainWindow : public Gtk::ApplicationWindow { string strtxtNtpServer; string str_zone=""; string str_zoneGlob; - + string array_region[14]={ + "Africa", + "America", + "Antarctica", + "Arctic", + "Asia", + "Atlantic", + "Australia", + "Brazil", + "Canada", + "Chile", + "Europe", + "Indian", + "Mexico", + "US"}; }; class SettingsPlug : public Gtk::Plug diff --git a/ubl-settings-datetime_ru.po b/ubl-settings-datetime_ru.po index 62612d7..4a9826f 100644 --- a/ubl-settings-datetime_ru.po +++ b/ubl-settings-datetime_ru.po @@ -6,6 +6,9 @@ msgid "" msgstr "" +msgid "Longyearbyen" +msgstr "Лонгйир" + msgid "Stop the synchronization service" msgstr "Остановить сервис синхронизации" @@ -232,13 +235,13 @@ msgid "Zaporozhye" msgstr "Запорожье" msgid "Cambridge_Bay" -msgstr "Кембридж_Бэй" +msgstr "Кембридж Бэй" msgid "Guayaquil" msgstr "Гуаякиль" msgid "Coral_Harbour" -msgstr "Корал_Харбор" +msgstr "Корал Харбор" msgid "Kigali" msgstr "Кигали" @@ -343,7 +346,7 @@ msgid "Canary" msgstr "Канари" msgid "Fort_Nelson" -msgstr "Форт_Нельсон" +msgstr "Форт Нельсон" msgid "Recife" msgstr "Ресифи" @@ -376,7 +379,7 @@ msgid "Ceuta" msgstr "Сеута" msgid "San_Marino" -msgstr "Сан_Марино" +msgstr "Сан Марино" msgid "Barnaul" msgstr "Барнаул" @@ -487,7 +490,7 @@ msgid "Novokuznetsk" msgstr "Новокузнецк" msgid "Dawson_Creek" -msgstr "Доусон_Крик" +msgstr "Доусон Крик" msgid "Srednekolymsk" msgstr "Среднеколымск" @@ -556,7 +559,7 @@ msgid "Jan_Mayen" msgstr "Ян_Майен" msgid "Acre" -msgstr "акр" +msgstr "Акр" msgid "Choibalsan" msgstr "Чойбалсан" @@ -841,7 +844,7 @@ msgid "Monaco" msgstr "Монако" msgid "Aleutian" -msgstr "алеутский" +msgstr "Алеутский" msgid "Montreal" msgstr "Монреаль" @@ -1231,7 +1234,7 @@ msgid "Rosario" msgstr "Росарио" msgid "LHI" -msgstr "LHI" +msgstr "Лхи" msgid "Bamako" msgstr "Бамако" @@ -1273,7 +1276,7 @@ msgid "Ust-Nera" msgstr "Усть-Нера" msgid "Arctic" -msgstr "Арктический" +msgstr "Арктика" msgid "Menominee" msgstr "Меномини" @@ -1453,7 +1456,7 @@ msgid "Tehran" msgstr "Тегеран" msgid "DumontDUrville" -msgstr "Дюмон-д’Юрвиль" +msgstr "Дюмон-д-Юрвиль" msgid "Enderbury" msgstr "Эндербери" @@ -1563,4 +1566,30 @@ msgstr "Банжул" msgid "Louisville" msgstr "Луисвилл" +msgid "Indiana" +msgstr "Индианан" + +msgid "North_Dokota" +msgstr "Северная Докота" + +msgid "Palmer" +msgstr "Палмер" + +msgid "Yekaterinburg" +msgstr "Екатеринбург" + +msgid "Cape_Vepde" +msgstr "Кабо-Верде" + +msgid "East" +msgstr "Восток" + +msgid "Easterlsland" +msgstr "Остров Пасхи" + +msgid "Mayotte" +msgstr "Майотта" + +msgid "BajaSur" +msgstr "Южная Нижняя Калифорния"