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

pull/35/head
Igor Belitskiy 3 years ago
parent 4f43bfcb60
commit 51eeb57b6b

@ -9,7 +9,7 @@ int main(int argc, char** argv) {
setlocale(LC_ALL, "");
bindtextdomain("ublexec", "/usr/share/locale/");
bind_textdomain_codeset("ublexec", "UTF-8");
textdomain("ublexec");
textdomain(app_name.c_str());
if (argc > 1){
str_argv = argv[1];
}
@ -66,7 +66,7 @@ void pars_flag(int index_start, int argc, char* argv[]) {
exit(1);
}
else if (str_argv == "--version" || str_argv == "-v"){
string version = string(gettext("ublexec version: ")) + version_application + "\n";
string version = string(str_version) + version_application + "\n";
cout << version.c_str();
exit(1);
}

@ -0,0 +1,61 @@
#ifndef MY_LOCALIZATION
#define MY_LOCALIZATION
#include <gtkmm/plug.h>
#define copyright _("Copyright © UBSoft LLC, 2022 - ")
#define define_name_app _("Run as...")
#define name_app_1 _("ublexec")
#define website _("https://wiki.ublinux.com")
#define home_page _("Project Home Page")
#define space_name_app _(" Run as...")
#define str_about_1 _("About")
#define str_about _("About ubl-settings-datetime")
#define str_help _("Help")
#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 _("ublexec version: ")
#define nice_19 _("19 (Low)")
#define nice_0 _("0 (High)")
#define nice__20 _("-20 (High)")
#define str_close _("Close")
#define str_localization_system _("System")
#define str_localization_development _("Development")
#define str_localization_other _("Other")
#define str_localization_office _("Office")
#define str_localization_education _("Education")
#define str_localization_settings _("Settings")
#define str_localization_multimedia _("Multimedia")
#define str_localization_internet _("Internet")
#define str_localization_tools _("Tools")
#define str_localization_graphics _("Graphics")
#define str_localization_attention _("Attention")
#define str_localization_priority _("Priority")
#define str_run_of_user _("Run as another user:")
#define str_select_app_program _("Select an executable file or program")
#define str_change_priority _("Change startup priority")
#define str_run_terminal _("Run in the terminal emulator")
#define str_file_overview _("File Overview")
#define str_application_overview _("Application Overview")
#define str_run_applications_as_another _("Run applications as another user\nwith the specified priority")
#define str_localization_username _("User Name:")
#define str_selecting_programs _("Selecting Programs")
#define str_please_select_file _("Please select File")
#define str_localization_cmd_line _("Command Line")
#define str_localization_user _("User")
#define str_localization_team _("Team:")
#define str_run _("Run")
#endif

@ -170,55 +170,54 @@ void MainWindow::localization() {
time_t now = time(0);
tm *ltm = localtime(&now);
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_copyright(str_authors);
aboutWindows->set_website(gettext("https://wiki.ublinux.com"));
btnSynopsis->set_label(gettext("Help"));
btnAbout->set_label(gettext("About"));
aboutWindows->set_comments(gettext("Run as..."));
aboutWindows->set_website_label(gettext("Project Home Page"));
aboutWindows->set_version(gettext(version_application.c_str()));
aboutWindows->set_title(gettext(" Run as..."));
lblHeaderAboutTopic->set_label(gettext(" Run as..."));
lblHeaderName->set_text(gettext("Run as..."));
this->set_title(gettext("Run as..."));
btnStart->set_label(gettext("Run"));
wndChooseFileWallpaper->set_title(gettext("Please select File"));
dialogStartMenu->set_title(gettext("Selecting Programs"));
lblInfoHead->set_text(gettext("Run applications as another user\nwith the specified priority"));
lblinfoCmd->set_text(gettext("Command Line"));
lblInfoTime->set_text(gettext("Team:"));
labInfoExecutTerm->set_text(gettext("Run in the terminal emulator"));
lblInfoUser->set_text(gettext("User"));
lblInfoUserOther->set_text(gettext("Run as another user:"));
lblInfoUserName->set_text(gettext("User Name:"));
lblInfoNooPriority->set_text(gettext("Priority"));
lblInfoExec->set_text(gettext("Change startup priority"));
lblInfoPriority->set_text(gettext("Priority:"));
lblMessageError->set_text(gettext("Select an executable file or program"));
messageError->set_title(gettext("Attention"));
lblGraphics->set_text(gettext("Graphics"));
lblTools->set_text(gettext("Tools"));
lblInternet->set_text(gettext("Internet"));
lblMultimedia->set_text(gettext("Multimedia"));
lblSettings->set_text(gettext("Settings"));
lblEducation->set_text(gettext("Education"));
lblOffice->set_text(gettext("Office"));
lblOther->set_text(gettext("Other"));
lblDevelopment->set_text(gettext("Development"));
lblSystem->set_text(gettext("System"));
btnListApp->set_tooltip_text(gettext("Application Overview"));
btnFilemaneg->set_tooltip_text(gettext("File Overview"));
btnMessageErrorOk->set_label(gettext("Close"));
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"));
lblHeadeWndWeb->set_label(_("Run as..."));
lblwebHeaderName->set_label(_("Run as..."));
aboutWindows->set_website(website);
btnSynopsis->set_label(str_help);
btnAbout->set_label(str_about_1);
aboutWindows->set_comments(define_name_app);
aboutWindows->set_website_label(home_page );
aboutWindows->set_version(_(version_application.c_str()));
aboutWindows->set_title(space_name_app );
lblHeaderAboutTopic->set_label(space_name_app );
lblHeaderName->set_text(define_name_app);
this->set_title(define_name_app);
btnStart->set_label(str_run);
wndChooseFileWallpaper->set_title(str_please_select_file);
dialogStartMenu->set_title(str_selecting_programs);
lblInfoHead->set_text(str_run_applications_as_another);
lblinfoCmd->set_text(str_localization_cmd_line);
lblInfoTime->set_text(str_localization_team);
labInfoExecutTerm->set_text(str_run_terminal);
lblInfoUser->set_text(str_localization_user);
lblInfoUserOther->set_text(str_run_of_user);
lblInfoUserName->set_text(str_localization_username);
lblInfoNooPriority->set_text(str_localization_priority);
lblInfoExec->set_text(str_change_priority);
lblInfoPriority->set_text(string(str_localization_priority) + ":");
lblMessageError->set_text(str_select_app_program);
messageError->set_title(str_localization_attention);
lblGraphics->set_text(str_localization_graphics);
lblTools->set_text(str_localization_tools);
lblInternet->set_text(str_localization_internet);
lblMultimedia->set_text(str_localization_multimedia);
lblSettings->set_text(str_localization_settings);
lblEducation->set_text(str_localization_education);
lblOffice->set_text(str_localization_office);
lblOther->set_text(str_localization_other);
lblDevelopment->set_text(str_localization_development);
lblSystem->set_text(str_localization_system);
btnListApp->set_tooltip_text(str_application_overview);
btnFilemaneg->set_tooltip_text(str_file_overview);
btnMessageErrorOk->set_label(str_close);
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_1);
lblHeadeWndWeb->set_label(define_name_app);
lblwebHeaderName->set_label(define_name_app);
}
void MainWindow::event() {
@ -270,32 +269,32 @@ void MainWindow::sudo_nice(){
spinPriority->set_increments(1.0, -1.0);
scalePriority->set_range(-20, 19);
scalePriority->set_value(0);
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
lblTime4EpriorityHigh->set_text(gettext("-20 (High)"));
lblTimeEpriorityLow->set_text(nice_19);
lblTime4EpriorityHigh->set_text(nice__20);
}
else if (rbSudo->get_active() && response.find("wheel") != string::npos){
spinPriority->set_range(-20, 19);
spinPriority->set_increments(1.0, -1.0);
scalePriority->set_range(-20, 19);
scalePriority->set_value(0);
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
lblTime4EpriorityHigh->set_text(gettext("-20 (High)"));
lblTimeEpriorityLow->set_text(nice_19);
lblTime4EpriorityHigh->set_text(nice__20);
}
else if (rbSu->get_active()){
spinPriority->set_range(0, 19);
spinPriority->set_increments(1.0, -1.0);
scalePriority->set_range(0, 19);
scalePriority->set_value(0);
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
lblTime4EpriorityHigh->set_text(gettext("0 (High)"));
lblTimeEpriorityLow->set_text(nice_19);
lblTime4EpriorityHigh->set_text(nice_0);
}
else if (rbPkexec->get_active()){
spinPriority->set_range(0, 19);
spinPriority->set_increments(1.0, -1.0);
scalePriority->set_range(0, 19);
scalePriority->set_value(0);
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
lblTime4EpriorityHigh->set_text(gettext("0 (High)"));
lblTimeEpriorityLow->set_text(nice_19);
lblTime4EpriorityHigh->set_text(nice_0);
}
this->denamic_cmd();
}
@ -309,16 +308,16 @@ void MainWindow::changed_user() {
spinPriority->set_increments(1.0, -1.0);
scalePriority->set_range(-20, 19);
scalePriority->set_value(0);
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
lblTime4EpriorityHigh->set_text(gettext("-20 (High)"));
lblTimeEpriorityLow->set_text(nice_19);
lblTime4EpriorityHigh->set_text(nice__20);
}
else{
spinPriority->set_range(0, 19);
spinPriority->set_increments(1.0, -1.0);
scalePriority->set_range(0, 19);
scalePriority->set_value(0);
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
lblTime4EpriorityHigh->set_text(gettext("0 (High)"));
lblTimeEpriorityLow->set_text(nice_19);
lblTime4EpriorityHigh->set_text(nice_0);
}
}
@ -365,7 +364,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();
@ -483,8 +482,8 @@ void MainWindow::settings() {
spinPriority->set_increments(1.0, -1.0);
scalePriority->set_range(0, 19);
scalePriority->set_value(0);
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
lblTime4EpriorityHigh->set_text(gettext("0 (High)"));
lblTimeEpriorityLow->set_text(nice_19);
lblTime4EpriorityHigh->set_text(nice_0);
scalePriority->set_inverted(true);
Gtk::Widget *boxWidget;
builder->get_widget("boxColor", boxWidget);
@ -693,7 +692,7 @@ string MainWindow::start_cmd(string user_cmd) {
str_nice_cmd = "nice -n " + to_string(spinPriority->get_value_as_int()) + " ";
}
if (user_cmd.length() == 0 && name_app.length() == 0 && path_file.length() == 0) {
messageError->set_title(gettext("Attention"));
messageError->set_title(str_localization_attention);
messageError->show();
return "";
}
@ -762,7 +761,7 @@ void MainWindow::denamic_cmd() {
name_app = "";
user_cmd = "";
txtCmd->set_text(user_cmd);
messageError->set_title(gettext("Attention"));
messageError->set_title(str_localization_attention);
messageError->show();
}
else{
@ -1031,14 +1030,7 @@ MainWindow::~MainWindow() {
}
void help() {
string help = "GTK \"Run applications as another user with the specified priority\" for UBLinux\n\n"
"Usage: ublexec [OPTIONS...]\n"
"Options:\n"
" -h, --help Show this help\n"
" -V, --version Show package version\n"
" -x APP_NAME Running the program\n"
" -e FILE_NAME Running the file\n";
cout << gettext(help.c_str());
cout << str_help_h;
}

@ -19,6 +19,7 @@
#include "ubl-util-standard.c"
#include "ublexec-cm.h"
#include "my_cmd.h"
#include "my_localization.h"
#ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h>
#endif

Loading…
Cancel
Save