From 64e765111dde29e7464ba49ec6185ef0d35077c8 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 13 Dec 2018 15:49:05 +0100 Subject: Add translations meson option to build and install translations --- lang/bg.ts | 698 ++++++++++++++++++++++++++++-------------- linux/poi_firejail.desktop.in | 2 +- meson.build | 1 + meson_options.txt | 3 +- src/builtins.cpp | 29 +- src/builtins.h | 3 +- src/main.cpp | 31 +- src/mainwindow/menubar.h | 2 + 8 files changed, 505 insertions(+), 264 deletions(-) diff --git a/lang/bg.ts b/lang/bg.ts index 4b8eb7a..4fae35d 100644 --- a/lang/bg.ts +++ b/lang/bg.ts @@ -13,7 +13,7 @@ - + TextLabel @@ -23,41 +23,115 @@ Лиценз - + Details Детайли - + + <h2>smolbote %1</h2><p><i>yet another no-frills browser</i></p><p>This program is free software, see <i>License</i> for more information.</p> + + + + + <p>Copyright 2017 - 2018 aqua</p><p>This program is free software, and you are welcome to use it under the conditions set by the GNU GPLv3.<br>This is a short summary: <ul><li> the freedom to use the software for any purpose,</li><li> the freedom to change the software to suit your needs,</li><li> the freedom to share the software with anyone,</li><li> the freedom to share the changes you make, and</li><li> the responsibility to grant the same freedoms when sharing the software.</li></ul><p>This program is distributed in the hope that it will be useful, but without any warranty.</p><p>You can read the full terms of the license on <a href='https://www.gnu.org/licenses/gpl-3.0.en.html'>the GNU website</a>.</p> + + + + + <p>Version + + + + + AboutPluginDialog + + + Dialog + + + + + General + Общи + + + Name Име - + Author Автор - + Shortcut - Клавишна комбинация + Клавишна комбинация + + + + License + Лиценз - - <h2>smolbote %1</h2><p><i>yet another no-frills browser</i></p><p>This program is free software, see <i>License</i> for more information.</p><p>This program uses free software: Qt + + Details + Детайли + + + + TextLabel - - <p>Copyright 2017 - 2018 aqua</p><p>This program is free software, and you are welcome to use it under the conditions set by the GNU GPLv3.<br>This is a short summary: <ul><li> the freedom to use the software for any purpose,</li><li> the freedom to change the software to suit your needs,</li><li> the freedom to share the software with anyone,</li><li> the freedom to share the changes you make, and</li><li> the responsibility to grant the same freedoms when sharing the software.</li></ul><p>This program is distributed in the hope that it will be useful, but without any warranty.</p> + + Key + Ключ + + + + Value - - <p>Version + + Controls + Контрол + + + + Load + Зареди + + + + Status + Статус + + + + AddressBar + + + Form + + BookmarkModel + + + Title + Име + + + + Address + Адрес + + BookmarksDialog @@ -81,28 +155,27 @@ Изтрий Елемент - - + Address Адрес - + Edit Bookmark Редактирай Отметка - + Title Име - + Edit Folder Редактирай Папка - + Name Име @@ -110,80 +183,28 @@ BookmarksWidget - - - title - - - - - href - + + + Title + Име Browser - - Bookmarks - Отметки - - - - Downloads - Сваляния - - - - CookiesForm - - - Cookies - Бисквитки - - - - Expiration - Изтича - - - - Details - Детайли - - - - Is HTTP Only - Само HTTP - - - - Is Secure - Сигурна - - - - Is Session Cookie - Сесийна - - - - Path - Път + + About + Относно - - - - yes - да + + Run + - - - - no - не + + Remove + Премахни @@ -217,7 +238,12 @@ - + + Open + + + + path_label @@ -225,27 +251,27 @@ DownloadItemWidget - + Requested Поискан - + In progress Изпълнява се - + Completed Изпълнен - + Cancelled Отменен - + Interrupted @@ -253,194 +279,244 @@ DownloadsWidget - + Downloads Сваляния - - Save - Запиши + + Save File + - MainWindow + EditBookmarkDialog + + + Edit Bookmark + Редактирай Отметка + - - MainWindow + + Title + Име + + + + Address + Адрес + + + + Tags - - s&molbote + + Description + + + MainWindow - - Session - Сесия + + Close multiple subwindows? + Затвори множество подпрозорци? - - Wi&ndow - Прозорец + + Do you want to close all subwindows? + Искате ли да затворите всички подпрозорци? + + + MenuBar - - Too&ls - Инструменти + + Find in menus + Намери в менютата - - Pa&ge - Страница + + + Save Session + Запиши сесия + + + + JSON (*.json) + JSON (*.json) + + + + Open Session + Отвори сесия + + + + Bookmarks + Отметки + + + + Downloads + Сваляния + + + + Load Plugin + Зареди добавка - - &New Subwindow - Нов Подпрозорец + + Select Plugin + Избери добавка - - New &Window - Нов Прозорец + + Plugins (*.so) + Добавки (*.so) - - &About + + About Относно - - A&bout Qt - Относно Qt + + Help + Помощ - - &Quit + + Quit Изход - - &Save Session - Запази Сесия + + Window + Прозорец + + + + New Window + Нов прозорец - - &Load Session - Зареди Сесия + + New Subwindow + Нов подпрозорец - - &Tile Windows + + Tile Subwindows - - &Cascade Windows + + Cascade Subwindows - - Current &Window - Сегашен Прозорец + + Subwindow + Подпрозорец - - &Create Bookmark - Създай Отметка + + New Tab + Нов таб - - &Save Page - Запиши Страница + + Restore last tab + Възстанови последния таб - - &Print Page - Отпечатай Страница + + Restore previous tab + Възстанови предишен таб - - P&rint to PDF - Отпечатай като PDF + + Subwindow Profile + Профил на подпрозореца - - Developer Tools - + + Page + Страница - - Save Session - Запиши сесия + + Create Bookmark + Направи отметка - - - JSON (*.json) - JSON (*.json) + + Save + Запиши - - Load Session - Зареди сесия + + Print + Отпечатай - + + Print to PDF - Отпечатай като PDF + Отпечатай като PDF - + PDF files (*.pdf) - PDF файлове (*.pdf) + PDF файлове (*.pdf) - - Load Profile - Зареди Профил + + Page Profile + Профил на страница - - Close multiple subwindows? - Затвори множество подпрозорци? + + Developer Tools + - - Do you want to close all subwindows? - Искате ли да затворите всички подпрозорци? + + View Source + + + + + MenuSearch + + + Find... + NavigationBar - + Back Назад - - Back (%1) - Назад (%1) - - - + Forward Напред - - Forward (%1) - Напред (%1) - - - + Refresh Презареди - + Home Начална страница @@ -448,52 +524,82 @@ QObject - + + The render process terminated normally. + + + + + The render process terminated with with a non-zero exit status. + + + + + The render process crashed, for example because of a segmentation fault. + + + + + The render process was killed, for example by SIGKILL or task manager kill. + + + + + The render process was terminated with an unknown status. + + + + Notifications - + Geolocation - + Audio Capture - + Video Capture - + Audio and Video Capture - + Mouse Lock - + Desktop Video Capture - + Desktop Audio and Video Capture - + + Unknown feature + + + + Developer Tools - + %1 (%2) @@ -526,42 +632,98 @@ Търсене + + SessionDialog + + + Select Session + + + + + Filter + + + + + Search + Търсене + + + + Open from File + + + + + Create a new window + + + + + Select Session file + + + + + JSON (*.json) + JSON (*.json) + + + + SessionForm + + + Form + + + + + TextLabel + + + + + ... + + + SubWindow - - + + Profile: %1 Профил: %1 - + Load profile Зареди Профил - - - Add tab - Добави таб - TabWidget - + Close Tab Затвори Таб - + Close Tabs left Затвори Табовете вляво - + Close Tabs right Затвори Табовете вдясно + + + Clear + + UrlLineEdit @@ -594,42 +756,42 @@ WebPage - + SSL Error SSL грешка - + An SSL error has occurred on <strong>%1</strong> SSL грешка на <string>%1</strong> - + <p>%1</p><p>This error %2 be overridden.</p> - + can - + cannot - + Error code: %1 Код на грешката: %1 - + Feature permission request - + <p>The webpage <strong>%1</strong> has requested permission to access: %2</p><p>Allow this feature?</p> @@ -637,70 +799,144 @@ WebView - + Back Назад - + Forward Напред - + Reload Презареди - + Reload and bypass Cache Презареди и заобиколи кеша - + Copy image to clipboard Копирай изображение - + Copy image URL to clipboard Копирай адреса на изображението - + + Open image + + + + Open image in new tab Отвори изображението в нов таб - + Save image Запиши изображение - + Open link in new tab Отвори линк в нов таб - + Open link in new tab with profile Отвори линк в нов таб с профил - + Open link in new window Отвори линк в нов прозорец - + Copy link address Копирай адрес на линка - - + + Zoom: %1x Увеличение: %1x + + + Autofill form + + + + + builtins + + + smolbote + smolbote + + + + : yet another no-frills browser + + : поредния опростен браузър + + + + + Usage: + Използване: + + + + [options] [command/URL(s)] + + + [опции] [командa/адрес(и)] + + + + + + Command-line Options: + + Командни опции: + + + + + Commands: + + Команди: + + + + + Configuration Options: + + Настройки: + + + + + For more information on usage, refer to the manual page smolbote.7 + + За повече информация относно използването на тази програма, вижте man smolbote.7 + + + + + For more information on configuration, refer to the manual page smolbote.5 + + За повече информация относно настройките на тази програма, вижте man smolbote.5 + + diff --git a/linux/poi_firejail.desktop.in b/linux/poi_firejail.desktop.in index 139ffde..31e5b64 100644 --- a/linux/poi_firejail.desktop.in +++ b/linux/poi_firejail.desktop.in @@ -3,7 +3,7 @@ Version=1.0 Name=smolbote (in firejail) GenericName=Web Browser Comment=yet another no-frills browser -Exec=@firejail@ --profile=@firejail_profile@ @exec_poi@ %u +Exec=@firejail@ --profile=@firejail_profile@ @exec_poi@ --mainwindow.title="[[smolbote]]" %u Icon=poi Terminal=false Type=Application diff --git a/meson.build b/meson.build index 06d52b6..9c2f0d3 100644 --- a/meson.build +++ b/meson.build @@ -70,6 +70,7 @@ subdir('lib/web') subdir('3rd-party/SingleApplication') subdir('src') +subdir('lang') subdir('doc') subdir('plugins/ConfigurationEditor') diff --git a/meson_options.txt b/meson_options.txt index f611a7f..ee219a7 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,7 +3,8 @@ option('poiName', description: 'Executable name', type: 'string', value: 'poi') option('firejail', description: 'firejail executable name', type: 'string', value: '/usr/bin/firejail') # Install options -option('manpage', description: 'Generate and install manpage', type: 'feature', value: 'auto') +option('manpage', description: 'Generate and install manpage', type: 'feature', value: 'auto') +option('translations', description: 'Generate and install translations', type: 'feature', value: 'auto') # Feature options option('Breakpad', description: 'Enable breakpad crash reporting', type: 'feature', value: 'auto') diff --git a/src/builtins.cpp b/src/builtins.cpp index 242a09f..8cfdb46 100644 --- a/src/builtins.cpp +++ b/src/builtins.cpp @@ -10,17 +10,22 @@ #include #include #include -#include +#include "version.h" +#include -inline std::string tr(const char *text) +inline const char* tr(const QTranslator *translator, const char *text) { - return QObject::tr(text).toStdString(); + const auto t = translator->translate("builtins", text); + if(t.isEmpty()) + return text; + else + return qUtf8Printable(t); } int builtins::version() { const auto version = QVersionNumber::fromString(QLatin1String(poi_Version)).toString().toStdString(); - std::cout << tr("smolbote ") << version << std::endl; + std::cout << "smolbote " << version << std::endl; return 0; } @@ -33,24 +38,24 @@ int builtins::build() int builtins::help(const char *cmd, boost::program_options::options_description cmd_opts, boost::program_options::options_description config_opts, - CommandHash_t pluginCommands) + CommandHash_t pluginCommands, const QTranslator *translator) { const auto version = QVersionNumber::fromString(QLatin1String(poi_Version)).toString().toStdString(); - std::cout << tr("smolbote ") << version << tr(": yet another no-frills browser\n"); - std::cout << tr("Usage: ") << cmd << tr(" [options] [command/URL(s)]\n\n"); + std::cout << tr(translator, "smolbote ") << version << tr(translator, ": yet another no-frills browser\n"); + std::cout << tr(translator, "Usage: ") << cmd << tr(translator, " [options] [command/URL(s)]\n\n"); - std::cout << tr("Command-line Options:\n") << cmd_opts << '\n'; + std::cout << tr(translator, "Command-line Options:\n") << cmd_opts << '\n'; - std::cout << tr("Commands: \n"); + std::cout << tr(translator, "Commands: \n"); for(auto it = pluginCommands.constBegin(); it != pluginCommands.constEnd(); ++it) std::cout << " " << it.key().toStdString() << '\n'; std::cout << '\n'; - std::cout << tr("Configuration Options:\n") << config_opts << '\n'; + std::cout << tr(translator, "Configuration Options:\n") << config_opts << '\n'; #ifdef Q_OS_UNIX - std::cout << tr("For more information on usage, refer to the manual page smolbote.7\n"); - std::cout << tr("For more information on configuration, refer to the manual page smolbote.5\n"); + std::cout << tr(translator, "For more information on usage, refer to the manual page smolbote.7\n"); + std::cout << tr(translator, "For more information on configuration, refer to the manual page smolbote.5\n"); #endif std::cout << std::endl; diff --git a/src/builtins.h b/src/builtins.h index 6c7153c..7ad8ba5 100644 --- a/src/builtins.h +++ b/src/builtins.h @@ -19,7 +19,8 @@ int build(); int help(const char *cmd, boost::program_options::options_description cmd_opts, boost::program_options::options_description config_opts, - CommandHash_t pluginCommands); + CommandHash_t pluginCommands, + const QTranslator *translator); } #endif diff --git a/src/main.cpp b/src/main.cpp index d9e1c6a..04ce57a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -65,6 +65,10 @@ int main(int argc, char **argv) // create and load configuration std::unique_ptr config = std::make_unique(argc, argv, cmd->value("config").value()); + QTranslator translator; + if(config->exists("browser.translation")) { + translator.load(config->value("browser.translation").value()); + } QVector plugins; CommandHash_t pluginCommands; @@ -88,13 +92,21 @@ int main(int argc, char **argv) } if(cmd->exists("help")) { - return builtins::help(argv[0], cmd->description(), config->description(), pluginCommands); + return builtins::help(argv[0], cmd->description(), config->description(), pluginCommands, &translator); } // argc, argv, allowSecondary Browser app(argc, argv); // set this, otherwise the webview becomes black when using a stylesheet app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true); + app.installTranslator(&translator); + if(config->exists("browser.locale")) { + auto *locale = new QTranslator(&app); + if(locale->load("qt_" + config->value("browser.locale").value(), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + app.installTranslator(locale); + else + delete locale; + } #ifdef CONFIG_USEBREAKPAD const std::string crashpath = config->value("browser.crash.path").value_or("/tmp"); @@ -119,23 +131,6 @@ int main(int argc, char **argv) #endif #endif // CONFIG_USEBREAKPAD - // translator - if(config->exists("browser.locale")) { - auto *translator = new QTranslator(&app); - if(translator->load("qt_" + config->value("browser.locale").value(), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) - app.installTranslator(translator); - else - delete translator; - } - - if(config->exists("browser.translation")) { - auto *translator = new QTranslator(&app); - if(translator->load(config->value("browser.translation").value())) - app.installTranslator(translator); - else - delete translator; - } - const bool isStandalone = cmd->exists("no-remote"); const auto profile = config->value("profile.default"); diff --git a/src/mainwindow/menubar.h b/src/mainwindow/menubar.h index 38b1286..7b592dd 100644 --- a/src/mainwindow/menubar.h +++ b/src/mainwindow/menubar.h @@ -15,6 +15,8 @@ class Configuration; class MainWindow; class MenuBar : public QMenuBar { + Q_OBJECT + public: MenuBar(const Configuration *config, MainWindow *parent = nullptr); -- cgit v1.2.1