Локализация вынесена в отдельный файл

pull/107/head
Igor Belitskiy 3 years ago
parent 16b276e862
commit 624ca395d7

@ -30,6 +30,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissin
-fstack-clash-protection -fcf-protection") -fstack-clash-protection -fcf-protection")
set(SOURCE_FILES set(SOURCE_FILES
my_localization.h
ubl-settings-datetime-cm.h ubl-settings-datetime-cm.h
ubl-util-standard.h ubl-util-standard.h
ubl-util-standard.c ubl-util-standard.c

@ -56,7 +56,7 @@ int main(int argc, char* argv[]) {
return r; return r;
} }
else{ else{
cout << gettext("Argument not recognized"); cout << no_recognized;
return 0; return 0;
} }
} }
@ -70,7 +70,7 @@ void pars_flag(int index_start, int argc, char* argv[]){
exit(1); exit(1);
} }
else if (str_argv == "--version" || str_argv == "-v"){ else if (str_argv == "--version" || str_argv == "-v"){
string version = string(gettext("ubl-settings-datetime version: ")) + version_application + "\n"; string version = string(str_version) + version_application + "\n";
cout << version.c_str(); cout << version.c_str();
exit(1); exit(1);
} }
@ -105,7 +105,7 @@ void pars_flag(int index_start, int argc, char* argv[]){
} }
else{ else{
if (index_start == 1){ if (index_start == 1){
g_print(gettext("Argument not recognized\n")); g_print(no_recognized);
} }
} }

@ -26,8 +26,13 @@
#define set_global_NTPSERVERS_dhcp "ubconfig --target global set network NTPSERVERS=dhcp" #define set_global_NTPSERVERS_dhcp "ubconfig --target global set network NTPSERVERS=dhcp"
#define set_global_NTPSERVERS "ubconfig --target global set network NTPSERVERS=\"" #define set_global_NTPSERVERS "ubconfig --target global set network NTPSERVERS=\""
#define set_hwclock "hwclock --systohc" #define set_hwclock "hwclock --systohc"
#define icon_checked "com.ublinux.ubl-settings-datetime.checked"
#define icon_warning "com.ublinux.ubl-settings-datetime.warning"
#define get_global_defalult_HWCLOCK_SYNC "ubconfig --default --source global get clock HWCLOCK_SYNC" #define get_global_defalult_HWCLOCK_SYNC "ubconfig --default --source global get clock HWCLOCK_SYNC"
#endif #endif

@ -0,0 +1,75 @@
#ifndef MY_LOCALIZATION
#define MY_LOCALIZATION
#include <gtkmm/plug.h>
#define copyright _("Copyright © UBSoft LLC, 2022 - ")
#define name_app _("ubl-settings-datetime")
#define website _("https://wiki.ublinux.com")
#define home_page _("Project Home Page")
#define str_about_1 _("About")
#define str_about _("About ubl-settings-datetime")
#define str_help _("Help")
#define str_about_1 _("About")
#define str_save _("Save")
#define str_load _("Load")
#define save_all _("Save to global and local configuration")
#define save_local _("Save local configuration")
#define save_global _("Save global configuration")
#define load_global _("Load global configuration")
#define load_local _("Load local configuration")
#define read_online _("Read online")
#define cancel _("Cancel")
#define always_redirect _("Always redirect")
#define nothing_save _("Nothing to save!")
#define read_documentation_web _("Would you like to read documentation in the Web?")
#define redirected_documentation _("You will be redirected to documentation site, where user help pages are ""translated and supported by community.")
#define str_help_h _("GTK settings datetime for UBLinux\n\n""Usage: ubl-settings-datetime [OPTIONS...]\n""Options:\n"" -h, --help Show this help\n"" -V, --version Show package version\n"" --lock-datetime Lock date and time changes\n"" --lock-timezone Lock time zone changes\n"" --lock-ntp-mode Lock NTP mode selection\n"" --lock-ntp-edit Lock editing NTP servers\n"" --lock-sync-hwclock Lock sync hwclock mode selection\n"" --lock-save Lock saving local and global configuration\n"" --lock-save-local Lock save global configuration\n"" --lock-save-global Lock load global configuration\n"" --lock-load-global Lock load global configuration\n")
#define str_version _("ubl-settings-datetime version: ")
#define local_read_error _("Local configuration reading error")
#define global_read_error _("Global configuration read error")
#define local_write_error _("Local configuration write error")
#define global_write_error _("Global configuration write error")
#define error_save_all _("Error saved local and global configuration")
#define local_load_ok _("Local configuration downloaded successfully")
#define global_load_ok _("Global configuration downloaded successfully")
#define local_ok_written _("Local configuration successfully written")
#define global_ok_written _("Global configuration successfully written")
#define successfully_save_all _("Successfully saved local and global configuration")
#define incorrect_date_f _("Incorrect date format")
#define date_time_ok_synchronized _("Date and time are successfully synchronized")
#define entry_list_ntp _("Enter a list of NTP servers")
#define error_ntp_name _("Error in the NTP server name")
#define invalid_character_entry _("An invalid character is entered")
#define ntp_server_ok _("NTP server name is correct")
#define hardware_clock_ok _("Hardware clock successfully synchronized")
#define hardware_clock_error _("Hardware clock synchronization error")
#define no_recognized _("Argument not recognized\n")
#define program_as_root _("The program must be run as root")
#define str_date_flag _(": \"Date\"")
#define str_time_zone_flag _(": \"Time Zone\"")
#define str_hardware_time_flag _(": \"Hardware time\"")
#define str_NTP_flag _(": \"NTP\"")
#define str_default _("Default")
#define str_DHCP _("DHCP")
#define str_manual _("Manual")
#define str_disabled _("Disabled")
#define str_time _("Time:")
#define str_date_time _("Date and Time")
#define utc_time _("UTC time")
#define str_local_time _("Local time")
#define str_attention _("Attention")
#define str_sync_by _("Sync by")
#define str_zone _("Zone:")
#define str_region _("Region:")
#define str_time_zone _("Time zone")
#define str_date _("Date:")
#define synchronize_hw _("Synchronize hardware time")
#define setting_date_time _("Setting the date and time")
#define current_date_time _("Current date and time")
#define data_format_d_m_y _("Date of\nFormat: DD.MM.YYYY")
#define synchronize_ntp _("Synchronize via NTP")
#define enter_name_ntp_tooltip _("Enter the name of the ntp-server or its ip-address.\nWhen entering multiple addresses, separate them with commas.")
#endif

@ -55,31 +55,31 @@ MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
} }
void MainWindow::settings() { void MainWindow::settings() {
map_error[get_system_ZONE] = string(gettext(": \"Time Zone\"")); map_error[get_system_ZONE] = string(str_time_zone_flag);
map_error[set_hwclock] = string(gettext(": \"Hardware time\"")); map_error[set_hwclock] = string(str_hardware_time_flag);
map_error[get_system_NTPSERVERS] = string(gettext(": \"NTP\"")); map_error[get_system_NTPSERVERS] = string(str_NTP_flag);
map_error[get_system_HWCLOCK_SYNC] = string(gettext(": \"Hardware time\"")); map_error[get_system_HWCLOCK_SYNC] = string(str_hardware_time_flag);
map_error[get_global_NTPSERVERS] = string(gettext(": \"NTP\"")); map_error[get_global_NTPSERVERS] = string(str_NTP_flag);
map_error[get_global_ZONE] = string(gettext(": \"Time Zone\"")); map_error[get_global_ZONE] = string(str_time_zone_flag);
map_error[get_global_defalult_HWCLOCK_SYNC] = string(gettext(": \"Hardware time\"")); map_error[get_global_defalult_HWCLOCK_SYNC] = string(str_hardware_time_flag);
map_error[get_global_HWCLOCK_SYNC] = string(gettext(": \"Hardware time\"")); map_error[get_global_HWCLOCK_SYNC] = string(str_hardware_time_flag);
map_error[set_system_ZONE] = string(gettext(": \"Time Zone\"")); map_error[set_system_ZONE] = string(str_time_zone_flag);
map_error[set_system_NTPSERVERS_default] = string(gettext(": \"NTP\"")); map_error[set_system_NTPSERVERS_default] = string(str_NTP_flag);
map_error[set_system_NTPSERVERS_dhcp] = string(gettext(": \"NTP\"")); map_error[set_system_NTPSERVERS_dhcp] = string(str_NTP_flag);
map_error[set_system_NTPSERVERS] = string(gettext(": \"NTP\"")); map_error[set_system_NTPSERVERS] = string(str_NTP_flag);
map_error[remove_system_NTPSERVERS] = string(gettext(": \"NTP\"")); map_error[remove_system_NTPSERVERS] = string(str_NTP_flag);
map_error[set_system_HWCLOCK_SYNC_localtime] = string(gettext(": \"Hardware time\"")); map_error[set_system_HWCLOCK_SYNC_localtime] = string(str_hardware_time_flag);
map_error[set_system_HWCLOCK_SYNC_utc] = string(gettext(": \"Hardware time\"")); map_error[set_system_HWCLOCK_SYNC_utc] = string(str_hardware_time_flag);
map_error[set_global_ZONE] = string(gettext(": \"Time Zone\"")); map_error[set_global_ZONE] = string(str_time_zone_flag);
map_error[set_global_NTPSERVERS_default] = string(gettext(": \"NTP\"")); map_error[set_global_NTPSERVERS_default] = string(str_NTP_flag);
map_error[set_global_NTPSERVERS_dhcp] = string(gettext(": \"NTP\"")); map_error[set_global_NTPSERVERS_dhcp] = string(str_NTP_flag);
map_error[set_global_NTPSERVERS] = string(gettext(": \"NTP\"")); map_error[set_global_NTPSERVERS] = string(str_NTP_flag);
map_error[remove_global_NTPSERVERS] = string(gettext(": \"NTP\"")); map_error[remove_global_NTPSERVERS] = string(str_NTP_flag);
map_error[set_global_HWCLOCK_SYNC_localtime] = string(gettext(": \"Hardware time\"")); map_error[set_global_HWCLOCK_SYNC_localtime] = string(str_hardware_time_flag);
map_error[set_global_HWCLOCK_SYNC_utc] = string(gettext(": \"Hardware time\"")); map_error[set_global_HWCLOCK_SYNC_utc] = string(str_hardware_time_flag);
map_error[get_NTPSERVERS_DEFAULT] = string(gettext(": \"NTP\"")); map_error[get_NTPSERVERS_DEFAULT] = string(str_NTP_flag);
map_error["date +%Y%m%d -s \""] = string(gettext(": \"Date\"")); map_error["date +%Y%m%d -s \""] = string(str_date_flag);
map_error["date +%T -s \""] = string(gettext(": \"Date\"")); map_error["date +%T -s \""] = string(str_date_flag);
this->get_builder(); this->get_builder();
this->add_CSS(); this->add_CSS();
Gtk::Widget *boxWidget; Gtk::Widget *boxWidget;
@ -117,9 +117,9 @@ void MainWindow::settings() {
boxButton->set_sensitive(false); boxButton->set_sensitive(false);
btnSave->set_sensitive(false); btnSave->set_sensitive(false);
this->event(); this->event();
imgInfo->set_from_icon_name("com.ublinux.ubl-settings-datetime.warning", Gtk::ICON_SIZE_MENU); imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU);
info_status_app("boxInfoMessError"); info_status_app("boxInfoMessError");
lblWarning->set_text(gettext("The program must be run as root")); lblWarning->set_text(program_as_root);
} }
} }
@ -127,51 +127,50 @@ void MainWindow::lacalization() {
time_t now = time(0); time_t now = time(0);
tm *ltm = localtime(&now); tm *ltm = localtime(&now);
unsigned int year = 1900+ ltm->tm_year; unsigned int year = 1900+ ltm->tm_year;
string str_authors = string(gettext("Copyright © UBSoft LLC, 2022 - ")) + to_string(year); string str_authors = string(copyright) + to_string(year);
aboutWindows->set_program_name(gettext("ubl-settings-datetime")); aboutWindows->set_program_name(name_app);
aboutWindows->set_copyright(str_authors); aboutWindows->set_copyright(str_authors);
aboutWindows->set_comments(gettext("Date and Time")); aboutWindows->set_comments(str_date_time);
aboutWindows->set_website(gettext("https://wiki.ublinux.com")); aboutWindows->set_website(website);
aboutWindows->set_version(gettext(version_application.c_str())); aboutWindows->set_version(_(version_application.c_str()));
aboutWindows->set_website_label(gettext("Project Home Page")); aboutWindows->set_website_label(home_page);
lblHeaderAboutTopic->set_label(gettext("About ubl-settings-datetime")); lblHeaderAboutTopic->set_label(str_about);
lblSave->set_label(gettext("Save")); lblSave->set_label(str_save);
lblLoad->set_label(gettext("Load")); lblLoad->set_label(str_load);
txtDate->set_tooltip_text(gettext("Date of\nFormat: DD.MM.YYYY")); txtDate->set_tooltip_text(data_format_d_m_y);
txtNtpServer->set_tooltip_text(gettext("Enter the name of the ntp-server or its ip-address.\nWhen entering multiple addresses, separate them with commas.")); txtNtpServer->set_tooltip_text(enter_name_ntp_tooltip);
lblSynchronizebChkGLob->set_text(gettext("Synchronize via NTP")); lblSynchronizebChkGLob->set_text(synchronize_ntp);
cbDhcp->append(gettext("Default")); cbDhcp->append(str_default);
cbDhcp->append(gettext("DHCP")); cbDhcp->append(str_DHCP);
cbDhcp->append(gettext("Manual")); cbDhcp->append(str_manual);
cbDhcp->append(gettext("Disabled")); cbDhcp->append(str_disabled);
lblDateTimeSetting->set_text(gettext("Current date and time")); lblDateTimeSetting->set_text(current_date_time);
lblHead->set_text(gettext("Setting the date and time")); lblHead->set_text(setting_date_time);
lblTime->set_text(gettext("Time:")); lblTime->set_text(str_time);
lblData->set_text(gettext("Date:")); lblData->set_text(str_date);
lblTimeZone->set_text(gettext("Time zone")); lblTimeZone->set_text(str_time_zone);
lblReg->set_text(gettext("Region:")); lblReg->set_text(str_region);
lblZone->set_text(gettext("Zone:")); lblZone->set_text(str_zone);
lblSynchronizeBtn->set_text(gettext("Sync by")); lblSynchronizeBtn->set_text(str_sync_by);
lblHeader->set_text(gettext("ubl-settings-datetime")); lblHeader->set_text(name_app);
lblHeadeWndWeb->set_text(gettext("ubl-settings-datetime")); lblHeadeWndWeb->set_text(name_app);
windowMessDchp->set_title(gettext("Attention")); windowMessDchp->set_title(str_attention);
lblTimeBios->set_text(gettext("Synchronize hardware time")); lblTimeBios->set_text(synchronize_hw);
lblHW->set_text(gettext("Synchronize hardware time:")); lblHW->set_text(string(synchronize_hw) + ":");
array_hw_local[0] = gettext("UTC time"); array_hw_local[0] = utc_time;
array_hw_local[1] = gettext("Local time"); array_hw_local[1] = str_local_time;
array_hw[0] = "utc"; array_hw[0] = "utc";
array_hw[1] = "localtime"; array_hw[1] = "localtime";
this->bubble_sort(array_hw, array_hw_local, 2); this->bubble_sort(array_hw, array_hw_local, 2);
cbHw->append(array_hw_local[0]); cbHw->append(array_hw_local[0]);
cbHw->append(array_hw_local[1]); cbHw->append(array_hw_local[1]);
lblhelpHeader->set_text(_("Would you like to read documentation in the Web?")); lblhelpHeader->set_text(read_documentation_web);
lblhelpText->set_text(_("You will be redirected to documentation site, where user help pages are " lblhelpText->set_text(redirected_documentation);
"translated and supported by community.")); btnReadHelp->set_label(read_online);
btnReadHelp->set_label(_("Read online")); btnCancelHelp->set_label(cancel);
btnCancelHelp->set_label(_("Cancel")); chkAlwaysOpenHelp->set_label(always_redirect);
chkAlwaysOpenHelp->set_label(_("Always redirect")); lblwebHeaderName->set_label(name_app);
lblwebHeaderName->set_label(_("ubl-settings-datetime"));
} }
void MainWindow::bubble_sort(string arr[],string arr_local[], int len_arr) { void MainWindow::bubble_sort(string arr[],string arr_local[], int len_arr) {
@ -426,7 +425,7 @@ void MainWindow::open_browser() {
webkit_web_view_load_uri(one, link_doc); webkit_web_view_load_uri(one, link_doc);
wndWeb->show_all(); wndWeb->show_all();
#else #else
string cmd = cmd_xdg + string(gettext(link_doc)) + " &"; string cmd = cmd_xdg + string(_(link_doc)) + " &";
string buf = ""; string buf = "";
if (geteuid() == 0) { if (geteuid() == 0) {
string response_user = getlogin(); string response_user = getlogin();
@ -470,7 +469,7 @@ void MainWindow::save_local_cfg() {
if ((this->check_config("region", 0) && this->check_config("zone", 0) && if ((this->check_config("region", 0) && this->check_config("zone", 0) &&
this->check_config("dhcp", 0) && this->check_config("hw", 0))) { this->check_config("dhcp", 0) && this->check_config("hw", 0))) {
info_status_app("boxInfoMessOK"); info_status_app("boxInfoMessOK");
lblWarning->set_text(gettext("Nothing to save!")); lblWarning->set_text(nothing_save);
} }
else { else {
string cmd_zone = set_system_ZONE; string cmd_zone = set_system_ZONE;
@ -499,7 +498,7 @@ void MainWindow::save_global_cfg() {
if ((this->check_config("region", 1) && this->check_config("zone", 1) && if ((this->check_config("region", 1) && this->check_config("zone", 1) &&
this->check_config("dhcp", 1) && this->check_config("hw", 1))) { this->check_config("dhcp", 1) && this->check_config("hw", 1))) {
info_status_app("boxInfoMessOK"); info_status_app("boxInfoMessOK");
lblWarning->set_text(gettext("Nothing to save!")); lblWarning->set_text(nothing_save);
} }
else { else {
string cmd = set_global_ZONE; string cmd = set_global_ZONE;
@ -530,7 +529,7 @@ void MainWindow::save_global_local_cfg() {
(this->check_config("region", 1) && this->check_config("zone", 1) && (this->check_config("region", 1) && this->check_config("zone", 1) &&
this->check_config("dhcp", 1) && this->check_config("hw", 1))) { this->check_config("dhcp", 1) && this->check_config("hw", 1))) {
info_status_app("boxInfoMessOK"); info_status_app("boxInfoMessOK");
lblWarning->set_text(gettext("Nothing to save!")); lblWarning->set_text(nothing_save);
} }
else { else {
string cmd = ""; string cmd = "";
@ -721,49 +720,49 @@ string MainWindow::get_ubconfig_value(string cmd){
void MainWindow::info_warning_error(int mess) { void MainWindow::info_warning_error(int mess) {
if (error_info > 0 || warning_info > 0) { if (error_info > 0 || warning_info > 0) {
info_status_app("boxInfoMessError"); info_status_app("boxInfoMessError");
imgInfo->set_from_icon_name("com.ublinux.ubl-settings-datetime.warning", Gtk::ICON_SIZE_MENU); imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU);
error_info = 0; error_info = 0;
warning_info = 0; warning_info = 0;
string mess_error = ""; string mess_error = "";
if (mess == 0) { if (mess == 0) {
mess_error = string(gettext("Local configuration reading error")) + cmd_error; mess_error = string(local_read_error) + cmd_error;
lblWarning->set_text(mess_error); lblWarning->set_text(mess_error);
} }
else if (mess == 1) { else if (mess == 1) {
mess_error = string(gettext("Global configuration read error")) + cmd_error; mess_error = string(global_read_error) + cmd_error;
lblWarning->set_text(mess_error); lblWarning->set_text(mess_error);
} }
else if (mess == 2) { else if (mess == 2) {
mess_error = string(gettext("Local configuration write error")) + cmd_error; mess_error = string(local_write_error) + cmd_error;
lblWarning->set_text(mess_error); lblWarning->set_text(mess_error);
} }
else if (mess == 3) { else if (mess == 3) {
mess_error = string(gettext("Global configuration write error")) + cmd_error; mess_error = string(global_write_error) + cmd_error;
lblWarning->set_text(mess_error); lblWarning->set_text(mess_error);
} }
else if (mess == 4) { else if (mess == 4) {
mess_error = string(gettext("Error saved local and global configuration")) + cmd_error; mess_error = string(error_save_all) + cmd_error;
lblWarning->set_text(mess_error); lblWarning->set_text(mess_error);
} }
cmd_error = ""; cmd_error = "";
} }
else { else {
info_status_app("boxInfoMessOK"); info_status_app("boxInfoMessOK");
imgInfo->set_from_icon_name("com.ublinux.ubl-settings-datetime.checked", Gtk::ICON_SIZE_MENU);//Gtk::IconSize::INHERIT); imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU);//Gtk::IconSize::INHERIT);
if (mess == 0) { if (mess == 0) {
lblWarning->set_text(gettext("Local configuration downloaded successfully")); lblWarning->set_text(local_load_ok);
} }
else if (mess == 1) { else if (mess == 1) {
lblWarning->set_text(gettext("Global configuration downloaded successfully")); lblWarning->set_text(global_load_ok);
} }
else if (mess == 2) { else if (mess == 2) {
lblWarning->set_text(gettext("Local configuration successfully written")); lblWarning->set_text(local_ok_written);
} }
else if (mess == 3) { else if (mess == 3) {
lblWarning->set_text(gettext("Global configuration successfully written")); lblWarning->set_text(global_ok_written);
} }
else if (mess == 4) { else if (mess == 4) {
lblWarning->set_text(gettext("Successfully saved local and global configuration")); lblWarning->set_text(successfully_save_all);
} }
} }
} }
@ -849,11 +848,11 @@ void MainWindow::hardware_clock() {
string cmd = set_hwclock; string cmd = set_hwclock;
wrapper_system(cmd); wrapper_system(cmd);
if (error_hw != error_info){ if (error_hw != error_info){
lblWarning->set_text(gettext("Hardware clock synchronization error")); lblWarning->set_text(hardware_clock_error);
info_status_app("boxInfoMessError"); info_status_app("boxInfoMessError");
} }
else { else {
lblWarning->set_text(gettext("Hardware clock successfully synchronized")); lblWarning->set_text(hardware_clock_ok);
info_status_app("boxInfoMessOK"); info_status_app("boxInfoMessOK");
} }
} }
@ -864,7 +863,7 @@ void MainWindow::gui_mess_close() {
bool MainWindow::focus_ntp_text() { bool MainWindow::focus_ntp_text() {
if (txtNtpServer->get_text() == "" || txtNtpServer->get_text() == " ") { if (txtNtpServer->get_text() == "" || txtNtpServer->get_text() == " ") {
lblWarning->set_text(gettext("Enter a list of NTP servers")); lblWarning->set_text(entry_list_ntp);
info_status_app("boxInfoMessError"); info_status_app("boxInfoMessError");
btnSave->set_sensitive(false); btnSave->set_sensitive(false);
return false; return false;
@ -888,19 +887,19 @@ bool MainWindow::focus_ntp_text() {
} }
if ((flag_error == false) && (flag_error_check_ntp == false)) { if ((flag_error == false) && (flag_error_check_ntp == false)) {
this->write_config(str_ntp, "dhcp"); this->write_config(str_ntp, "dhcp");
lblWarning->set_text(gettext("NTP server name is correct")); lblWarning->set_text(ntp_server_ok);
info_status_app("boxInfoMessOK"); info_status_app("boxInfoMessOK");
btnSave->set_sensitive(true); btnSave->set_sensitive(true);
return true; return true;
} }
else { else {
if (flag_error == true) { if (flag_error == true) {
lblWarning->set_text(gettext("An invalid character is entered")); lblWarning->set_text(invalid_character_entry);
info_status_app("boxInfoMessError"); info_status_app("boxInfoMessError");
btnSave->set_sensitive(false); btnSave->set_sensitive(false);
} }
else if (flag_error_check_ntp == true) { else if (flag_error_check_ntp == true) {
lblWarning->set_text(gettext("Error in the NTP server name")); lblWarning->set_text(error_ntp_name);
info_status_app("boxInfoMessError"); info_status_app("boxInfoMessError");
btnSave->set_sensitive(false); btnSave->set_sensitive(false);
} }
@ -1136,7 +1135,7 @@ void MainWindow::entry_dhcp_mess(string cmd_get_dhcp, string cmd_default_get_dhc
// btnUpdateDateTime->set_sensitive(false); // btnUpdateDateTime->set_sensitive(false);
if (str_dhcp == "") { if (str_dhcp == "") {
this->write_config("", "dhcp"); this->write_config("", "dhcp");
lblWarning->set_text(gettext("Enter a list of NTP servers")); lblWarning->set_text(entry_list_ntp);
info_status_app("boxInfoMessError"); info_status_app("boxInfoMessError");
btnSave->set_sensitive(false); btnSave->set_sensitive(false);
} }
@ -1282,19 +1281,19 @@ void MainWindow::enter_zone(string &cmd) {
index+= 1; index+= 1;
} }
if (!(zone_text.empty())) { if (!(zone_text.empty())) {
str_zone = zone_text; str_zone_buff = zone_text;
str_region = reg_text; str_region_buff = reg_text;
cmd = cmd + str_region + "/" + str_zone; cmd = cmd + str_region_buff + "/" + str_zone_buff;
wrapper_system(cmd, "&"); wrapper_system(cmd, "&");
} }
else { else {
str_zone = ""; str_zone_buff = "";
str_region = ""; str_region_buff = "";
} }
} }
else { else {
str_zone = ""; str_zone_buff = "";
str_region = ""; str_region_buff = "";
} }
} }
@ -1310,13 +1309,13 @@ void MainWindow::parse_text_date() {
void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxText *tmpCbReg, Gtk::ComboBoxText *tmpCbZone) { void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxText *tmpCbReg, Gtk::ComboBoxText *tmpCbZone) {
this->write_config(region, "region"); this->write_config(region, "region");
this->write_config(zone, "zone"); this->write_config(zone, "zone");
str_region = region; str_region_buff = region;
int index = 0; int index = 0;
Glib::ustring reg_local = ""; Glib::ustring reg_local = "";
int size_vec = array_region_local.size(); int size_vec = array_region_local.size();
if (size_vec== 0) { if (size_vec== 0) {
for (auto& [key, value]: time_reg_map) { for (auto& [key, value]: time_reg_map) {
array_region_local.push_back(string(gettext(key.c_str()))); array_region_local.push_back(string(_(key.c_str())));
array_region.push_back(key); array_region.push_back(key);
index += 1; index += 1;
} }
@ -1342,7 +1341,7 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex
if (size_vec == 0) { if (size_vec == 0) {
tmpCbReg->append(Glib::ustring(reg)); tmpCbReg->append(Glib::ustring(reg));
} }
if (reg == string(gettext(region.c_str()))) { if (reg == string(_(region.c_str()))) {
tmpCbReg->set_active_text(reg); tmpCbReg->set_active_text(reg);
} }
} }
@ -1352,7 +1351,7 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex
string path_reg_zone = ""; string path_reg_zone = "";
string zone_offest = ""; string zone_offest = "";
path_reg_zone = region + "/" + zone; path_reg_zone = region + "/" + zone;
zone_offest = this->zone_file_read(path_reg_zone) + gettext(zone.c_str()); zone_offest = this->zone_file_read(path_reg_zone) + _(zone.c_str());
if (region == "") { if (region == "") {
tmpCbZone->append(" "); tmpCbZone->append(" ");
tmpCbZone->set_active(0); tmpCbZone->set_active(0);
@ -1412,12 +1411,12 @@ void MainWindow::append_zone() {
cbZone->remove_all(); cbZone->remove_all();
int index = cbRegion->get_active_row_number(); int index = cbRegion->get_active_row_number();
if (index!=-1) { if (index!=-1) {
string str_region = array_region[index]; string str_region_buff = array_region[index];
string zone_mixing = ""; string zone_mixing = "";
this->write_config(str_region, "region"); this->write_config(str_region_buff, "region");
string path_dir = ""; string path_dir = "";
if(str_region.length() != 0) { if(str_region_buff.length() != 0) {
for (const auto &_str_zone : time_reg_map_local.at(str_region)) { for (const auto &_str_zone : time_reg_map_local.at(str_region_buff)) {
cbZone->append(Glib::ustring(_str_zone)); cbZone->append(Glib::ustring(_str_zone));
} }
} }
@ -1456,7 +1455,7 @@ void MainWindow::update_time_date() {
year = 0; year = 0;
month = 0; month = 0;
day = 0; day = 0;
lblWarning->set_text(gettext("Date and time are successfully synchronized")); lblWarning->set_text(date_time_ok_synchronized);
info_status_app("boxInfoMessOK"); info_status_app("boxInfoMessOK");
flag_error_time = false; flag_error_time = false;
} }
@ -1474,7 +1473,7 @@ void MainWindow::update_time_date() {
day = 0; day = 0;
} }
if (flag_error_time == false) { if (flag_error_time == false) {
lblWarning->set_text(gettext("Date and time are successfully synchronized")); lblWarning->set_text(date_time_ok_synchronized);
info_status_app("boxInfoMessOK"); info_status_app("boxInfoMessOK");
hour = numTimeHrs->get_value_as_int(); hour = numTimeHrs->get_value_as_int();
minute = numTimeMin->get_value_as_int(); minute = numTimeMin->get_value_as_int();
@ -1500,18 +1499,18 @@ bool MainWindow::post_entry_data() {
string str_error_clock = this->call(cmd); string str_error_clock = this->call(cmd);
size_t index = str_error_clock.find("date:"); size_t index = str_error_clock.find("date:");
if (index != std::string::npos) { if (index != std::string::npos) {
lblWarning->set_text(gettext("Incorrect date format")); lblWarning->set_text(incorrect_date_f);
info_status_app("boxInfoMessError"); info_status_app("boxInfoMessError");
return true; return true;
} }
else { else {
lblWarning->set_text(gettext("Date and time are successfully synchronized")); lblWarning->set_text(date_time_ok_synchronized);
info_status_app("boxInfoMessOK"); info_status_app("boxInfoMessOK");
return false; return false;
} }
} }
else { else {
lblWarning->set_text(gettext("Incorrect date format")); lblWarning->set_text(incorrect_date_f);
info_status_app("boxInfoMessError"); info_status_app("boxInfoMessError");
return true; return true;
} }
@ -1577,7 +1576,7 @@ void MainWindow::read_file() {
string reg_reg_zone = entry_reg_reg_zone.path().filename().string(); string reg_reg_zone = entry_reg_reg_zone.path().filename().string();
zone.push_back(reg_reg_zone); zone.push_back(reg_reg_zone);
path_reg_zone=key_reg + "/" + reg_reg_zone; path_reg_zone=key_reg + "/" + reg_reg_zone;
key_zone_local = this->zone_file_read(path_reg_zone) + gettext(reg_reg_zone.c_str()); key_zone_local = this->zone_file_read(path_reg_zone) + _(reg_reg_zone.c_str());
zone_local.push_back(key_zone_local); zone_local.push_back(key_zone_local);
} }
in2.close(); in2.close();
@ -1586,7 +1585,7 @@ void MainWindow::read_file() {
else if (key_zone.length() != 0 || key_zone != " ") { else if (key_zone.length() != 0 || key_zone != " ") {
zone.push_back(key_zone); zone.push_back(key_zone);
path_reg_zone = key_reg + "/" + key_zone; path_reg_zone = key_reg + "/" + key_zone;
key_zone_local = this->zone_file_read(path_reg_zone) + gettext(key_zone.c_str()); key_zone_local = this->zone_file_read(path_reg_zone) + _(key_zone.c_str());
zone_local.push_back(key_zone_local); zone_local.push_back(key_zone_local);
} }
} }
@ -1714,24 +1713,9 @@ SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> build
} }
void help() { void help() {
string version = string(gettext("ubl-settings-datetime version: ")) + version_application + "\n"; string version = string(str_version) + version_application + "\n";
cout << version.c_str(); cout << version.c_str();;
string help; cout << str_help_h;
help = "GTK settings datetime for UBLinux\n\n"
"Usage: ubl-settings-datetime [OPTIONS...]\n"
"Options:\n"
" -h, --help Show this help\n"
" -V, --version Show package version\n"
" --lock-datetime Lock date and time changes\n"
" --lock-timezone Lock time zone changes\n"
" --lock-ntp-mode Lock NTP mode selection\n"
" --lock-ntp-edit Lock editing NTP servers\n"
" --lock-sync-hwclock Lock sync hwclock mode selection\n"
" --lock-save Lock saving local and global configuration\n"
" --lock-save-local Lock save global configuration\n"
" --lock-save-global Lock load global configuration\n"
" --lock-load-global Lock load global configuration\n";
cout << gettext(help.c_str());
} }

@ -20,6 +20,7 @@
#include "ubl-util-standard.c" #include "ubl-util-standard.c"
#include "my_cmd.h" #include "my_cmd.h"
#include "ubl-settings-datetime-cm.h" #include "ubl-settings-datetime-cm.h"
#include "my_localization.h"
#ifdef WEBKIT_FOUND #ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h> #include <webkit2/webkit2.h>
#endif #endif
@ -148,8 +149,8 @@ class MainWindow : public Gtk::ApplicationWindow {
int flag_local_global_load = 2; int flag_local_global_load = 2;
int hour; int hour;
int minute; int minute;
string str_region = ""; string str_region_buff = "";
string str_zone = ""; string str_zone_buff = "";
int count_edit = 0; int count_edit = 0;
bool flag_global = false; bool flag_global = false;
bool flag_local = false; bool flag_local = false;

Loading…
Cancel
Save