Сделана локализация зон и регионов

pull/31/head
Igor Belitskiy 3 years ago
parent bf90b3505e
commit 63c22343e3

@ -9,8 +9,8 @@ link_directories(${GTK_LIBRARY_DIRS})
add_definitions(${GTK_CFLAGS_OTHER}) add_definitions(${GTK_CFLAGS_OTHER})
find_package(ICU REQUIRED COMPONENTS uc dt in io) 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 -std=c++2a")
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")
set(SOURCE_FILES set(SOURCE_FILES
main.cc main.cc

@ -114,39 +114,39 @@ void MainWindow::settings(){
int MainWindow::check_root(){ int MainWindow::check_root(){
if (geteuid()!=0){ 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(); mess_sudo->show();
return 1; return 1;
} }
return 0; return 0;
} }
void MainWindow::lacalization(){ void MainWindow::lacalization(){
txtDate->set_tooltip_text(gettext("Date of\nFormat: DD.MM.YYYY")); txtDate->set_tooltip_text(_("Date of\nFormat: DD.MM.YYYY"));
lblSynchronizebChkGLob->set_text(gettext("Synchronize via NTP")); lblSynchronizebChkGLob->set_text(_("Synchronize via NTP"));
cbDhcp->append(gettext("By default")); cbDhcp->append(_("By default"));
cbDhcp->append(gettext("DHCP")); cbDhcp->append(_("DHCP"));
cbDhcp->append(gettext("Manually")); cbDhcp->append(_("Manually"));
lblDateTimeSetting->set_text(gettext("Local Configuration")); lblDateTimeSetting->set_text(_("Local Configuration"));
lblHead->set_text(gettext("Settings the date and time")); lblHead->set_text(_("Settings the date and time"));
lblTime->set_text(gettext("Time")); lblTime->set_text(_("Time"));
lblData->set_text(gettext("Date")); lblData->set_text(_("Date"));
lblTimeZone->set_text(gettext("Time zone")); lblTimeZone->set_text(_("Time zone"));
lblReg->set_text(gettext("Region")); lblReg->set_text(_("Region"));
lblZone->set_text(gettext("Zone")); lblZone->set_text(_("Zone"));
lblRegGlob->set_text(gettext("Region")); lblRegGlob->set_text(_("Region"));
lblZone1Glob->set_text(gettext("Zone")); lblZone1Glob->set_text(_("Zone"));
lblTimeZoneGlob->set_text(gettext("Time zone")); lblTimeZoneGlob->set_text(_("Time zone"));
lblSynchronizeBtn->set_text(gettext("Sync by")); lblSynchronizeBtn->set_text(_("Sync by"));
lblDateTimeSettingGlob->set_text(gettext("Global customization")); lblDateTimeSettingGlob->set_text(_("Global customization"));
this->set_title(gettext("ubl-settings-datetime")); this->set_title(_("ubl-settings-datetime"));
windowsNnpClose->set_title(gettext("Warning!")); windowsNnpClose->set_title(_("Warning!"));
mess_sudo->set_title(gettext("Warning!")); mess_sudo->set_title(_("Warning!"));
mess_dchp->set_title(gettext("Warning!")); mess_dchp->set_title(_("Warning!"));
lblTimeBios->set_text(gettext("Synchronize hardware time")); lblTimeBios->set_text(_("Synchronize hardware time"));
lblBanerStopNtp->set_text(gettext("Active service detected\nAutomatic time and date synchronization service detected")); lblBanerStopNtp->set_text(_("Active service detected\nAutomatic time and date synchronization service detected"));
lblNtpStop->set_text(gettext("Stop the synchronization service")); lblNtpStop->set_text(_("Stop the synchronization service"));
lblNtpClose->set_text(gettext("Close")); lblNtpClose->set_text(_("Close"));
//_lblSynchronizebChk->set_text(gettext("Synchronize via NTP")); //_lblSynchronizebChk->set_text(_("Synchronize via NTP"));
} }
void MainWindow::flag_block_gui(){ void MainWindow::flag_block_gui(){
@ -320,7 +320,7 @@ void MainWindow::gui_mess_close(){
bool MainWindow::focus_ntp(GdkEventFocus* event){ bool MainWindow::focus_ntp(GdkEventFocus* event){
if (event!=NULL){} if (event!=NULL){}
if (txtNtpServer->get_text()=="" || txtNtpServer->get_text()==" "){ if (txtNtpServer->get_text()=="" || txtNtpServer->get_text()==" "){
lblMessage->set_text(gettext("Enter DHCP!")); lblMessage->set_text(_("Enter DHCP!"));
mess_dchp->show(); mess_dchp->show();
} }
else{ else{
@ -335,7 +335,6 @@ bool MainWindow::focus_ntp(GdkEventFocus* event){
void MainWindow::event_entry_cbDhcp(){ void MainWindow::event_entry_cbDhcp(){
Glib::ustring str_dhcp = cbDhcp->get_active_text(); Glib::ustring str_dhcp = cbDhcp->get_active_text();
int activ_index = cbDhcp->get_active_row_number(); int activ_index = cbDhcp->get_active_row_number();
cout << activ_index << endl;
if (str_dhcp.length()!=0){ if (str_dhcp.length()!=0){
if (activ_index==0){ if (activ_index==0){
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default"; string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default";
@ -443,7 +442,7 @@ void MainWindow::enry_dhcp_mess(){
} }
else{ else{
if (str_dhcp==""){ if (str_dhcp==""){
lblMessage->set_text(gettext("Enter DHCP!")); lblMessage->set_text(_("Enter DHCP!"));
mess_dchp->show(); mess_dchp->show();
} }
else if (str_dhcp=="(null)"){ 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")); str_filling_zon = str_filling_zon.substr(0,str_filling_zon.find("\n"));
string str_zone_check = ""; string str_zone_check = "";
this->append_region_zone(str_filling_reg,str_filling_zon); this->append_region_zone(str_filling_reg,str_filling_zon);
//this->append_region_zone("Africa","Abidjan");
} }
else { else {
this->append_region_zone("Africa","Abidjan"); this->append_region_zone("Africa","Abidjan");
@ -487,8 +487,9 @@ void MainWindow::get_config(){
} }
void MainWindow::enter_zone(){ void MainWindow::enter_zone(){
string reg_text = cbRegion->get_active_text(); int activ_index_reg = cbRegion->get_active_row_number();
int activ_index = cbZone->get_active_row_number(); string reg_text=array_region[activ_index_reg];
int activ_index = cbZone->get_active_row_number();
string zone_text = ""; string zone_text = "";
if(!(reg_text.empty())){ if(!(reg_text.empty())){
int index=0; int index=0;
@ -527,7 +528,8 @@ void MainWindow::parse_text_date(){
} }
void MainWindow::enter_zone_glob(){ 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(); int activ_index = cbZoneGlob->get_active_row_number();
string zone_text=""; string zone_text="";
if(!(reg_text.empty())){ if(!(reg_text.empty())){
@ -569,29 +571,34 @@ void MainWindow::set_ntp_toggle_glob(){
} }
void MainWindow::append_region_zone(string region, string zone){ void MainWindow::append_region_zone(string region, string zone){
str_region=region;
str_region_glob=region;
int index = 0; int index = 0;
string reg_local = ""; Glib::ustring reg_local = "";
for (auto &text : time_reg_map ) { for (const auto &text : array_region) {
reg_local = text.first; reg_local = text;
//reg_local = string(gettext(reg_local.c_str())); reg_local = string(_(reg_local.c_str()));
cbRegion->append(reg_local); cbRegion->append(Glib::ustring(reg_local));
cbRegionGlob->append(reg_local); cbRegionGlob->append(Glib::ustring(reg_local));
if (text.first == region){ if (text == region){
cbRegionGlob->set_active(index); cbRegionGlob->set_active_text(reg_local);
cbRegion->set_active(index); cbRegion->set_active_text(reg_local);
} }
index+=1; index+=1;
} }
index = 0; index = 0;
string zone_mixing = ""; string zone_mixing = "";
string path_dir = ""; string path_reg_zone = "";
for (const auto &_str_zone : time_reg_map.at(region)){ string zone_offest = "";
path_dir=region+"/"+_str_zone; path_reg_zone=region+"/"+zone;
zone_mixing = this->zone_file_read(path_dir) + string(gettext(_str_zone.c_str())); 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); cbZone->append(zone_mixing);
cbZoneGlob->append(zone_mixing); cbZoneGlob->append(zone_mixing);
cout <<_str_zone << endl;
if (_str_zone!=""){ if (_str_zone!=""){
if (_str_zone == zone){ if (zone_offest == _str_zone){
cbZone->set_active(index); cbZone->set_active(index);
cbZoneGlob->set_active(index); cbZoneGlob->set_active(index);
} }
@ -621,34 +628,33 @@ string MainWindow::call(string cmd){
} }
void MainWindow::append_zone(){ void MainWindow::append_zone(){
//int length_zone = time_reg_map.at(str_region).size();
cbZone->remove_all(); 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 zone_mixing="";
string path_dir=""; string path_dir="";
if(!(text.empty())){ if(str_region.length()!=0){
str_region = text; for (const auto &_str_zone : time_reg_map_local.at(str_region)){
for (const auto &_str_zone : time_reg_map.at(str_region)){ cbZone->append(Glib::ustring(_str_zone));
path_dir=str_region+"/"+_str_zone;
zone_mixing = this->zone_file_read(path_dir) + string(gettext(_str_zone.c_str()));
cbZone->append(zone_mixing);
} }
} }
cbZone->set_active(0);
} }
void MainWindow::append_zone_glob(){ void MainWindow::append_zone_glob(){
cbZoneGlob->remove_all(); 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 zone_mixing="";
string path_dir=""; string path_dir="";
if(!(text.empty())){ if(str_region_glob.length()!=0){
str_region_glob = text; for (const auto &_str_zone : time_reg_map_local.at(str_region_glob)){
for (const auto &_str_zone : time_reg_map.at(str_region_glob)){ cbZoneGlob->append(Glib::ustring(_str_zone));
path_dir=str_region+"/"+_str_zone;
zone_mixing = this->zone_file_read(path_dir) + string(gettext(_str_zone.c_str()));
cbZoneGlob->append(zone_mixing);
} }
} }
cbZoneGlob->set_active(0);
} }
void MainWindow::wrapper_update_time_date(){ void MainWindow::wrapper_update_time_date(){
string cmd = "pidof systemd-timesyncd ntpd chronyd"; string cmd = "pidof systemd-timesyncd ntpd chronyd";
@ -726,7 +732,7 @@ void MainWindow::post_entry_data(){
} }
} }
else{ else{
lblMessage->set_text(gettext("Incorrect date format")); lblMessage->set_text(_("Incorrect date format"));
mess_dchp->show(); mess_dchp->show();
} }
} }
@ -765,6 +771,8 @@ void MainWindow::update_calendar(){
void MainWindow::read_file(){ void MainWindow::read_file(){
std::string line; std::string line;
string key_zone_local = "";
string path_reg_zone = "";
namespace fs = std::filesystem; namespace fs = std::filesystem;
for (const auto & entry : fs::directory_iterator("/usr/share/zoneinfo/")){ for (const auto & entry : fs::directory_iterator("/usr/share/zoneinfo/")){
std::ifstream in(entry.path()); // окрываем файл для чтения std::ifstream in(entry.path()); // окрываем файл для чтения
@ -777,6 +785,7 @@ void MainWindow::read_file(){
if (key_reg!="Etc"){ if (key_reg!="Etc"){
if (key_reg!="right"){ if (key_reg!="right"){
vector<string> zone; vector<string> zone;
vector<string> zone_local;
//zone.push_back(""); //zone.push_back("");
for (const auto & entry_zone : fs::directory_iterator(path_dir)){ for (const auto & entry_zone : fs::directory_iterator(path_dir)){
std::ifstream in1(entry_zone.path()); // окрываем файл для чтения std::ifstream in1(entry_zone.path()); // окрываем файл для чтения
@ -784,13 +793,16 @@ void MainWindow::read_file(){
string key_zone = entry_zone.path().filename().string(); string key_zone = entry_zone.path().filename().string();
if (key_zone.length()!=0 || key_zone!=" "){ if (key_zone.length()!=0 || key_zone!=" "){
zone.push_back(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(); 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});
}}}} }}}}
} }
} }

@ -121,7 +121,7 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::Entry *txtNtpServer; Gtk::Entry *txtNtpServer;
Gtk::Entry *txtDate; Gtk::Entry *txtDate;
std::map <string, vector<string>> time_reg_map; std::map <string, vector<string>> time_reg_map;
std::map <string, string> time_reg_map_local; std::map <string, vector<string>> time_reg_map_local;
unsigned int year=0; unsigned int year=0;
unsigned int month=0; unsigned int month=0;
unsigned int day=0; unsigned int day=0;
@ -133,7 +133,21 @@ class MainWindow : public Gtk::ApplicationWindow {
string strtxtNtpServer; string strtxtNtpServer;
string str_zone=""; string str_zone="";
string str_zoneGlob; 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 class SettingsPlug : public Gtk::Plug

@ -6,6 +6,9 @@
msgid "" msgid ""
msgstr "" msgstr ""
msgid "Longyearbyen"
msgstr "Лонгйир"
msgid "Stop the synchronization service" msgid "Stop the synchronization service"
msgstr "Остановить сервис синхронизации" msgstr "Остановить сервис синхронизации"
@ -232,13 +235,13 @@ msgid "Zaporozhye"
msgstr "Запорожье" msgstr "Запорожье"
msgid "Cambridge_Bay" msgid "Cambridge_Bay"
msgstr "Кембридж_Бэй" msgstr "Кембридж Бэй"
msgid "Guayaquil" msgid "Guayaquil"
msgstr "Гуаякиль" msgstr "Гуаякиль"
msgid "Coral_Harbour" msgid "Coral_Harbour"
msgstr "Корал_Харбор" msgstr "Корал Харбор"
msgid "Kigali" msgid "Kigali"
msgstr "Кигали" msgstr "Кигали"
@ -343,7 +346,7 @@ msgid "Canary"
msgstr "Канари" msgstr "Канари"
msgid "Fort_Nelson" msgid "Fort_Nelson"
msgstr "Форт_Нельсон" msgstr "Форт Нельсон"
msgid "Recife" msgid "Recife"
msgstr "Ресифи" msgstr "Ресифи"
@ -376,7 +379,7 @@ msgid "Ceuta"
msgstr "Сеута" msgstr "Сеута"
msgid "San_Marino" msgid "San_Marino"
msgstr "Сан_Марино" msgstr "Сан Марино"
msgid "Barnaul" msgid "Barnaul"
msgstr "Барнаул" msgstr "Барнаул"
@ -487,7 +490,7 @@ msgid "Novokuznetsk"
msgstr "Новокузнецк" msgstr "Новокузнецк"
msgid "Dawson_Creek" msgid "Dawson_Creek"
msgstr "Доусон_Крик" msgstr "Доусон Крик"
msgid "Srednekolymsk" msgid "Srednekolymsk"
msgstr "Среднеколымск" msgstr "Среднеколымск"
@ -556,7 +559,7 @@ msgid "Jan_Mayen"
msgstr "Ян_Майен" msgstr "Ян_Майен"
msgid "Acre" msgid "Acre"
msgstr "акр" msgstr "Акр"
msgid "Choibalsan" msgid "Choibalsan"
msgstr "Чойбалсан" msgstr "Чойбалсан"
@ -841,7 +844,7 @@ msgid "Monaco"
msgstr "Монако" msgstr "Монако"
msgid "Aleutian" msgid "Aleutian"
msgstr "алеутский" msgstr "Алеутский"
msgid "Montreal" msgid "Montreal"
msgstr "Монреаль" msgstr "Монреаль"
@ -1231,7 +1234,7 @@ msgid "Rosario"
msgstr "Росарио" msgstr "Росарио"
msgid "LHI" msgid "LHI"
msgstr "LHI" msgstr "Лхи"
msgid "Bamako" msgid "Bamako"
msgstr "Бамако" msgstr "Бамако"
@ -1273,7 +1276,7 @@ msgid "Ust-Nera"
msgstr "Усть-Нера" msgstr "Усть-Нера"
msgid "Arctic" msgid "Arctic"
msgstr "Арктический" msgstr "Арктика"
msgid "Menominee" msgid "Menominee"
msgstr "Меномини" msgstr "Меномини"
@ -1453,7 +1456,7 @@ msgid "Tehran"
msgstr "Тегеран" msgstr "Тегеран"
msgid "DumontDUrville" msgid "DumontDUrville"
msgstr "Дюмон-дЮрвиль" msgstr "Дюмон-д-Юрвиль"
msgid "Enderbury" msgid "Enderbury"
msgstr "Эндербери" msgstr "Эндербери"
@ -1563,4 +1566,30 @@ msgstr "Банжул"
msgid "Louisville" msgid "Louisville"
msgstr "Луисвилл" 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 "Южная Нижняя Калифорния"

Loading…
Cancel
Save