diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index dc55e84..c58563a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -31,6 +31,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissin -fstack-clash-protection -fcf-protection") set(SOURCE_FILES + my_localization.h ubl-settings-bootloader-cm.h ubl-settings-bootloader.h ubl-settings-bootloader.cc diff --git a/source/main.cc b/source/main.cc index bc66d05..edab5c2 100644 --- a/source/main.cc +++ b/source/main.cc @@ -62,7 +62,7 @@ void pars_flag(int index_start, int argc, char* argv[]) { exit(1); } else if (str_argv == "--version" || str_argv == "-v"){ - string version = string(_("ubl-settings-bootloader version: ")) + version_application + "\n"; + string version = string(str_version) + version_application + "\n"; cout << version.c_str(); exit(1); } @@ -85,7 +85,7 @@ void pars_flag(int index_start, int argc, char* argv[]) { } else{ if (index_start == 1){ - g_print(_("Argument not recognized\n")); + g_print(_(no_recognized)); } } diff --git a/source/my_cmd.h b/source/my_cmd.h index 34c7867..f8e9e2a 100644 --- a/source/my_cmd.h +++ b/source/my_cmd.h @@ -12,4 +12,6 @@ #define link_doc "https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-bootloader" #define cmd_xdg "xdg-open " #define cmd_execute "su -l %s -c \" DISPLAY=$DISPLAY %s \"" +#define icon_checked "com.ublinux.ubl-settings-bootloader.checked" +#define icon_warning "com.ublinux.ubl-settings-bootloader.warning" #endif \ No newline at end of file diff --git a/source/my_localization.h b/source/my_localization.h new file mode 100644 index 0000000..4bd86cb --- /dev/null +++ b/source/my_localization.h @@ -0,0 +1,64 @@ + +#ifndef MY_LOCALIZATION +#define MY_LOCALIZATION +#include +#define copyright _("Copyright © UBSoft LLC, 2022 - ") +#define name_app _("ubl-settings-bootloader") +#define website _("https://wiki.ublinux.com") +#define project_Home_page _("Project Home Page") +#define configuring_system_boot _("Configuring system boot parameters") +#define system_boot _("System boot") +#define str_about _("About ubl-settings-bootloader") +#define command_line_parameters _("Command line parameters:") +#define load_default _("Load default:") +#define seconds _("seconds") +#define download_menu _("Download menu") +#define terminal_for_input _("Terminal for input") +#define terminal_for_output _("Terminal for output") +#define boot_selection_menu_timer _("Boot selection menu timer") +#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 boot_screen_display_mode _("Boot screen display mode:") +#define no_loading_animation _("No loading animation, full log") +#define boot_menu_user_name _("Boot menu user name:") +#define boot_menu_user_password _("Boot menu user password:") +#define last_successful_upload _("Last successful upload") +#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 user_name_configuration_editing_code _("User name to enter boot configuration editing mode") +#define user_password_configuration_edit_mode _("User password to enter boot configuration edit mode") +#define loading_animation_with _("Loading animation with the magazine") +#define loading_animation_without _("Loading animation without a magazine") +#define lack_loading_animation _("Lack of loading animation with the output of the abbreviated log") +#define web_url _("https://wiki.ublinux.com") +#define enter_password _("Enter your password") +#define enter_login _("Enter login") +#define str_version _("ubl-settings-bootloader 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 nothing_save _("Nothing to save!") +#define program_as_root _("The program must be run as root") +#define str_active _("Active") +#define str_option _("Option") +#define str_description _("Description") +#define str_help_h _("GTK settings bootloader for UBLinux\n""\n""Usage: ubl-settings-bootloader [OPTIONS...]\n""Options:\n"" -h, --help\t Show this help\n"" -V, --version\t Show package version\n"" --lock-help Lock utility help\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 no_recognized _("Argument not recognized\n") +#endif \ No newline at end of file diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index ab57923..aeb5a52 100755 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -54,8 +54,6 @@ SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr build int MainWindow::check_root() { if (geteuid() != 0) { - //lblMessageSudo->set_text(_("The program must be run with \nsuperuser privileges!")); - //mess_sudo->show(); return 1; } return 0; @@ -111,9 +109,9 @@ void MainWindow::settings(){ boxWidgetAll->set_sensitive(false); btnLoad->set_sensitive(false); btnSave->set_sensitive(false); - imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.warning", Gtk::ICON_SIZE_MENU); + imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU); info_status_app("boxInfoMessError"); - lblWarning->set_text(_("The program must be run as root")); + lblWarning->set_text(program_as_root); this->set_active_boot_second(); this->fill_in_view(); } @@ -358,9 +356,9 @@ vector MainWindow::read_file_and_view(string file_name ,Gtk::TreeModel:: } void MainWindow::view_add_colums(Gtk::TreeView &treeView) { - treeView.append_column_editable(_("Active"), m_columns.check_button); - treeView.append_column(_("Option"), m_columns.name); - treeView.append_column(_("Description"), m_columns.description); + treeView.append_column_editable(str_active, m_columns.check_button); + treeView.append_column(str_option, m_columns.name); + treeView.append_column(str_description, m_columns.description); } void MainWindow::view_add_cell(Gtk::TreeModel::Row &row, Glib::RefPtr list_store_m , std::array, 5> &arr_view , size_t index) { @@ -443,59 +441,58 @@ void MainWindow::localization(){ time_t now = time(0); tm *ltm = localtime(&now); unsigned int year = 1900+ ltm->tm_year; - string str_authors = string(_("Copyright © UBSoft LLC, 2022 - ")) + to_string(year); - aboutWindows->set_program_name(gettext("ubl-settings-bootloader")); + string str_authors = string(copyright) + to_string(year); + aboutWindows->set_program_name(name_app); aboutWindows->set_copyright(str_authors); - aboutWindows->set_comments(_("ubl-settings-bootloader")); - aboutWindows->set_website(_("https://wiki.ublinux.com")); + aboutWindows->set_comments(name_app); + aboutWindows->set_website(web_url); aboutWindows->set_version(_(version_application.c_str())); - aboutWindows->set_website_label(_("Project Home Page")); - lblInfoHead->set_text(_("Configuring system boot parameters")); - lblHeaderName->set_text(_("ubl-settings-bootloader")); - aboutWindows->set_comments(_("System boot")); - lblHeaderAboutTopic->set_label(gettext("About ubl-settings-bootloader")); - aboutWindows->set_website_label(_("Project Home Page")); - lblInfoCommand->set_text(_("Command line parameters:")); - lblInfoCommand1->set_text(_("Command line parameters:")); - lblInfoCommand2->set_text(_("Command line parameters:")); - lblInfoDefaultDonw->set_text(_("Load default:")); - lblInfoSeconds->set_text(_("seconds")); - lblLoadMenu->set_text(_("Download menu")); - lblInfoInputTerminal->set_text(_("Terminal for input")); - lblInfoOutputTerminal->set_text(_("Terminal for output")); - chbLoadVariantSelectionTimer->set_label(_("Boot selection menu timer")); - btnSynopsis->set_label(_("Help")); - btnAbout->set_label(_("About")); - lblHeadeWndWeb->set_text(_("ubl-settings-bootloader")); - btnSaveLocalGlob->set_label(_("Save to global and local configuration")); - btnSaveLocal->set_label(_("Save local configuration")); - btnSaveGlob->set_label(_("Save global configuration")); - btnLoadGlob->set_label(_("Load global configuration")); - btnLoadLocal->set_label(_("Load local configuration")); - btnSave->set_label(_("Save")); - btnLoad->set_label(_("Load")); - this->set_title(_("ubl-settings-bootloader")); + aboutWindows->set_website_label(project_Home_page); + lblInfoHead->set_text(configuring_system_boot); + lblHeaderName->set_text(name_app); + aboutWindows->set_comments(system_boot); + lblHeaderAboutTopic->set_label(str_about); + aboutWindows->set_website_label(project_Home_page); + lblInfoCommand->set_text(command_line_parameters); + lblInfoCommand1->set_text(command_line_parameters); + lblInfoCommand2->set_text(command_line_parameters); + lblInfoDefaultDonw->set_text(str_about); + lblInfoSeconds->set_text(seconds); + lblLoadMenu->set_text(download_menu); + lblInfoInputTerminal->set_text(terminal_for_input); + lblInfoOutputTerminal->set_text(terminal_for_output); + chbLoadVariantSelectionTimer->set_label(boot_selection_menu_timer); + btnSynopsis->set_label(str_help); + btnAbout->set_label(str_about_1); + lblHeadeWndWeb->set_text(name_app); + btnSaveLocalGlob->set_label(save_all); + btnSaveLocal->set_label(save_local); + btnSaveGlob->set_label(save_global); + btnLoadGlob->set_label(load_global); + btnLoadLocal->set_label(load_local); + btnSave->set_label(str_save); + btnLoad->set_label(str_load); + this->set_title(name_app); // Todo: check - entrySecurityLogin->set_tooltip_text(gettext("User name to enter boot configuration editing mode")); - entryPasswordProtecc->set_tooltip_text(gettext("User password to enter boot configuration edit mode")); - chbSecurityLogin->set_tooltip_text(gettext("User name to enter boot configuration editing mode")); - chbPasswordProtecc->set_tooltip_text(gettext("User password to enter boot configuration edit mode")); - lblDownloadMode->set_text(_("Boot screen display mode:")); - chbSecurityLogin->set_label(_("Boot menu user name:")); - chbPasswordProtecc->set_label(_("Boot menu user password:")); - cmbDownloadMode->append(_("Loading animation with the magazine")); - cmbDownloadMode->append(_("Loading animation without a magazine")); - cmbDownloadMode->append(_("Нет анимации загрузки, полный журнал")); - cmbDownloadMode->append(_("Lack of loading animation with the output of the abbreviated log")); - cmbDefaultDonw->append(_("Last successful upload")); - - lblhelpHeader->set_text(_("Would you like to read documentation in the Web?")); - lblhelpText->set_text(_("You will be redirected to documentation site, where user help pages are " - "translated and supported by community.")); - btnReadHelp->set_label(_("Read online")); - btnCancelHelp->set_label(_("Cancel")); - chkAlwaysOpenHelp->set_label(_("Always redirect")); - lblwebHeaderName->set_label(_("ubl-settings-bootloader")); + entrySecurityLogin->set_tooltip_text(loading_animation_without); + entryPasswordProtecc->set_tooltip_text(user_password_configuration_edit_mode); + chbSecurityLogin->set_tooltip_text(loading_animation_without); + chbPasswordProtecc->set_tooltip_text(user_password_configuration_edit_mode); + lblDownloadMode->set_text(boot_screen_display_mode); + chbSecurityLogin->set_label(boot_screen_display_mode); + chbPasswordProtecc->set_label(boot_menu_user_password); + cmbDownloadMode->append(loading_animation_with); + cmbDownloadMode->append(loading_animation_without); + cmbDownloadMode->append(no_loading_animation); + cmbDownloadMode->append(lack_loading_animation); + cmbDefaultDonw->append(last_successful_upload); + + lblhelpHeader->set_text(read_documentation_web); + lblhelpText->set_text(_(redirected_documentation)); + btnReadHelp->set_label(read_online); + btnCancelHelp->set_label(cancel); + chkAlwaysOpenHelp->set_label(always_redirect); + lblwebHeaderName->set_label(name_app); } vector MainWindow::get_setting_entry_all(string key, std::map * map_temp) { @@ -518,13 +515,13 @@ vector MainWindow::get_setting_entry_all(string key, std::map get_text().length() == 0) { info_status_app("boxInfoMessError"); - imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.warning", Gtk::ICON_SIZE_MENU); - lblWarning->set_text(_("Enter your password")); + imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU); + lblWarning->set_text(enter_password); boxSave->set_sensitive(false); } else { info_status_app("boxInfoMessOK"); - imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.checked", Gtk::ICON_SIZE_MENU); + imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU); lblWarning->set_text(""); boxSave->set_sensitive(true); string key = entryPasswordProtecc->get_text(); @@ -538,13 +535,13 @@ bool MainWindow::focus_out_txt_password(GdkEventFocus*) { bool MainWindow::focus_out_txt_login(GdkEventFocus*) { if (entrySecurityLogin->get_text().length() == 0) { info_status_app("boxInfoMessError"); - imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.warning", Gtk::ICON_SIZE_MENU); - lblWarning->set_text(_("Enter login")); + imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU); + lblWarning->set_text(enter_login); boxSave->set_sensitive(false); } else { info_status_app("boxInfoMessOK"); - imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.checked", Gtk::ICON_SIZE_MENU); + imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU); lblWarning->set_text(""); map_cmd_selection["GRUB_USER"] = entrySecurityLogin->get_text(); boxSave->set_sensitive(true); @@ -665,7 +662,7 @@ void MainWindow::change_security_login() { entrySecurityLogin->set_text(""); boxSave->set_sensitive(true); info_status_app("boxInfoMessOK"); - imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.checked", Gtk::ICON_SIZE_MENU); + imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU); lblWarning->set_text(""); } else if (index == true) { @@ -700,7 +697,7 @@ void MainWindow::change_password_protecc() { entryPasswordProtecc->set_text(""); boxSave->set_sensitive(true); info_status_app("boxInfoMessOK"); - imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.checked", Gtk::ICON_SIZE_MENU); + imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU); lblWarning->set_text(""); } else if (index == true) { @@ -924,7 +921,7 @@ void MainWindow::open_browser() { webkit_web_view_load_uri(one, link_doc); wndWeb->show_all(); #else - string cmd = cmd_xdg + string(gettext(link_doc)) + " &"; + string cmd = cmd_xdg + string(_(link_doc)) + " &"; string buf = ""; if (geteuid() == 0) { string response_user = getlogin(); @@ -947,26 +944,26 @@ void MainWindow::info_status_app(string stule) { void MainWindow::info_warning_error(int mess) { if (obj_load.get_count_error() > 0 || obj_save.get_count_error() > 0) { info_status_app("boxInfoMessError"); - imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.warning", Gtk::ICON_SIZE_MENU); + imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU); string mess_error = ""; if (mess == 0) { - mess_error = string(_("Local configuration reading error")) + str_cmd_error; + mess_error = string(local_read_error) + str_cmd_error; lblWarning->set_text(mess_error); } else if (mess == 1) { - mess_error = string(_("Global configuration read error")) + str_cmd_error; + mess_error = string(global_read_error) + str_cmd_error; lblWarning->set_text(mess_error); } else if (mess == 2) { - mess_error = string(_("Local configuration write error")) + str_cmd_error; + mess_error = string(local_write_error) + str_cmd_error; lblWarning->set_text(mess_error); } else if (mess == 3) { - mess_error = string(_("Global configuration write error")) + str_cmd_error; + mess_error = string(global_write_error) + str_cmd_error; lblWarning->set_text(mess_error); } else if (mess == 4) { - mess_error = string(_("Error saved local and global configuration")) + str_cmd_error; + mess_error = string(error_save_all) + str_cmd_error; lblWarning->set_text(mess_error); } str_cmd_error = ""; @@ -975,24 +972,24 @@ void MainWindow::info_warning_error(int mess) { } else { info_status_app("boxInfoMessOK"); - imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.checked", Gtk::ICON_SIZE_MENU); + imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU); if (mess == 0) { - lblWarning->set_text(_("Local configuration downloaded successfully")); + lblWarning->set_text(local_load_ok); } else if (mess == 1) { - lblWarning->set_text(_("Global configuration downloaded successfully")); + lblWarning->set_text(global_load_ok); } else if (mess == 2) { - lblWarning->set_text(_("Local configuration successfully written")); + lblWarning->set_text(local_ok_written); } else if (mess == 3) { - lblWarning->set_text(_("Global configuration successfully written")); + lblWarning->set_text(global_ok_written); } else if (mess == 4) { - lblWarning->set_text(_("Successfully saved local and global configuration")); + lblWarning->set_text(successfully_save_all); } else if (mess == 5) { - lblWarning->set_text(_("Nothing to save!")); + lblWarning->set_text(nothing_save); } } } @@ -1001,6 +998,7 @@ MainWindow::~MainWindow() { free(one); #endif } + void MainWindow::add_CSS(){ Glib::RefPtr cssProvider = Gtk::CssProvider::create(); cssProvider->load_from_path(path_css); @@ -1020,21 +1018,10 @@ void MainWindow::add_CSS(){ } void help() { - string version = string(_("ubl-settings-bootloader version: ")) + version_application + "\n"; - cout << version.c_str(); + string version = string(str_version) + version_application + "\n"; + cout << version; string help; - help = "GTK settings bootloader for UBLinux\n" - "\n" - "Usage: ubl-settings-bootloader [OPTIONS...]\n" - "Options:\n" - " -h, --help\t Show this help\n" - " -V, --version\t Show package version\n" - " --lock-help Lock utility help\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 << _(help.c_str()); + cout << str_help_h; } diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index 0557ade..ef07669 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -21,6 +21,7 @@ #ifdef WEBKIT_FOUND #include #endif +#include "my_localization.h" #include "my_process.h" using namespace std; diff --git a/ubl-settings-bootloader.pot b/ubl-settings-bootloader.pot index c0b9030..d19a63c 100644 --- a/ubl-settings-bootloader.pot +++ b/ubl-settings-bootloader.pot @@ -17,7 +17,6 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" - msgid "Would you like to read documentation in the Web?" msgstr "" diff --git a/ubl-settings-bootloader_ru.po b/ubl-settings-bootloader_ru.po index 6d412a4..180ba69 100644 --- a/ubl-settings-bootloader_ru.po +++ b/ubl-settings-bootloader_ru.po @@ -457,15 +457,11 @@ msgstr "usb_keyboard (Клавиатура USB Keyboard (protocol HID Boot))" msgid "vga_text (Text output VGA (Coreboot))" msgstr "vga_text (Текстовый вывод VGA (Coreboot))" -#: source/ubl-settings-bootloader.cc:450 -msgid "Нет анимации загрузки, полный журнал" -msgstr "" - #~ msgid "Mine" #~ msgstr "Свой" #~ msgid "Disabled" #~ msgstr "Отключён" -#~ msgid "No loading animation, full log" -#~ msgstr "Отсутствие анимации загрузки с выводом журнала" +msgid "No loading animation, full log1" +msgstr "Отсутствие анимации загрузки с выводом журнала"