mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-24 04:32:15 -04:00
replace translations
This commit is contained in:
parent
7251c89c7d
commit
716d7b59cb
@ -1,4 +1,5 @@
|
||||
#include "fullscreennotification.h"
|
||||
#include "kiwixapp.h"
|
||||
#include <QSequentialAnimationGroup>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QPropertyAnimation>
|
||||
@ -7,7 +8,7 @@ FullScreenNotification::FullScreenNotification(QWidget *parent)
|
||||
: QLabel(parent)
|
||||
, m_previouslyVisible(false)
|
||||
{
|
||||
setText(tr("You are now in full screen mode. Press ESC to quit!"));
|
||||
setText(gt("fullscreen-notification"));
|
||||
setStyleSheet(
|
||||
"font-size: 24px;"
|
||||
"color: white;"
|
||||
|
@ -40,8 +40,8 @@ KiwixApp::KiwixApp(int& argc, char *argv[])
|
||||
try {
|
||||
mp_downloader = new kiwix::Downloader();
|
||||
} catch (exception& e) {
|
||||
QMessageBox::critical(nullptr, tr("Cannot create downloader"),
|
||||
tr("Impossible to launch downloader, Kiwix-desktop will start but all download functions will not working !<br><br>") + e.what());
|
||||
QMessageBox::critical(nullptr, gt("error-downloader-window-title"),
|
||||
gt("error-downloader-launch-message") + "<br><br>" + e.what());
|
||||
}
|
||||
mp_manager = new ContentManager(&m_library, mp_downloader);
|
||||
|
||||
@ -133,13 +133,17 @@ KiwixApp *KiwixApp::instance()
|
||||
return static_cast<KiwixApp*>(QApplication::instance());
|
||||
}
|
||||
|
||||
QString gt(const QString &key) {
|
||||
return KiwixApp::instance()->getText(key);
|
||||
}
|
||||
|
||||
void KiwixApp::openZimFile(const QString &zimfile)
|
||||
{
|
||||
QString _zimfile = zimfile;
|
||||
if (_zimfile.isEmpty()) {
|
||||
_zimfile = QFileDialog::getOpenFileName(
|
||||
getMainWindow(),
|
||||
tr("Open Zim"),
|
||||
gt("open-zim"),
|
||||
QString(),
|
||||
"ZimFile (*.zim*)");
|
||||
_zimfile = QDir::toNativeSeparators(_zimfile);
|
||||
@ -267,43 +271,43 @@ bool KiwixApp::isCurrentArticleBookmarked()
|
||||
|
||||
void KiwixApp::createAction()
|
||||
{
|
||||
CREATE_ACTION_ICON(KiwixServeAction, "share", tr("Local Kiwix Server"));
|
||||
CREATE_ACTION_ICON(KiwixServeAction, "share", gt("local-kiwix-server"));
|
||||
SET_SHORTCUT(KiwixServeAction, QKeySequence(Qt::CTRL+Qt::Key_I));
|
||||
|
||||
CREATE_ACTION_ICON(RandomArticleAction, "random", tr("Random Article"));
|
||||
CREATE_ACTION_ICON(RandomArticleAction, "random", gt("random-article"));
|
||||
SET_SHORTCUT(RandomArticleAction, QKeySequence(Qt::CTRL+Qt::Key_R));
|
||||
connect(mpa_actions[RandomArticleAction], &QAction::triggered,
|
||||
this, [=]() { this->openRandomUrl(false); });
|
||||
|
||||
CREATE_ACTION(OpenHomePageAction, tr("Home page"));
|
||||
CREATE_ACTION(OpenHomePageAction, gt("random-article"));
|
||||
SET_SHORTCUT(OpenHomePageAction, QKeySequence(Qt::ALT + Qt::Key_Home));
|
||||
|
||||
CREATE_ACTION_ICON(PrintAction, "print", tr("Print"));
|
||||
CREATE_ACTION_ICON(PrintAction, "print", gt("print"));
|
||||
SET_SHORTCUT(PrintAction, QKeySequence::Print);
|
||||
connect(mpa_actions[PrintAction], &QAction::triggered,
|
||||
this, &KiwixApp::printPage);
|
||||
|
||||
CREATE_ACTION(NewTabAction, tr("New tab"));
|
||||
CREATE_ACTION(NewTabAction, gt("new-tab"));
|
||||
SET_SHORTCUT(NewTabAction, QKeySequence::AddTab);
|
||||
|
||||
CREATE_ACTION_ICON(CloseTabAction, "close", tr("Close tab"));
|
||||
CREATE_ACTION_ICON(CloseTabAction, "close", gt("close-tab"));
|
||||
SET_SHORTCUT(CloseTabAction, QKeySequence::Close);
|
||||
mpa_actions[CloseTabAction]->setIconVisibleInMenu(false);
|
||||
|
||||
CREATE_ACTION(ReopenClosedTabAction, tr("Reopen closed tab"));
|
||||
CREATE_ACTION(ReopenClosedTabAction, gt("reopen-closed-tab"));
|
||||
SET_SHORTCUT(ReopenClosedTabAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_T));
|
||||
HIDE_ACTION(ReopenClosedTabAction);
|
||||
|
||||
CREATE_ACTION(BrowseLibraryAction, tr("Browse library"));
|
||||
CREATE_ACTION(BrowseLibraryAction, gt("browse-library"));
|
||||
SET_SHORTCUT(BrowseLibraryAction, QKeySequence(Qt::CTRL+Qt::Key_E));
|
||||
HIDE_ACTION(BrowseLibraryAction);
|
||||
|
||||
CREATE_ACTION_ICON(OpenFileAction, "open-file", tr("Open file"));
|
||||
CREATE_ACTION_ICON(OpenFileAction, "open-file", gt("open-file"));
|
||||
SET_SHORTCUT(OpenFileAction, QKeySequence::Open);
|
||||
connect(mpa_actions[OpenFileAction], &QAction::triggered,
|
||||
this, [=]() { openZimFile(); });
|
||||
|
||||
CREATE_ACTION(OpenRecentAction, tr("Open recent"));
|
||||
CREATE_ACTION(OpenRecentAction, gt("open-recent"));
|
||||
HIDE_ACTION(OpenRecentAction);
|
||||
|
||||
/* TODO See https://github.com/kiwix/kiwix-desktop/issues/77
|
||||
@ -312,35 +316,35 @@ void KiwixApp::createAction()
|
||||
HIDE_ACTION(SavePageAsAction);
|
||||
*/
|
||||
|
||||
CREATE_ACTION(SearchArticleAction, tr("Search article"));
|
||||
CREATE_ACTION(SearchArticleAction, gt("search-article"));
|
||||
SET_SHORTCUT(SearchArticleAction, QKeySequence(Qt::CTRL+Qt::Key_L));
|
||||
HIDE_ACTION(SearchArticleAction);
|
||||
|
||||
CREATE_ACTION(SearchLibraryAction, tr("Search in library"));
|
||||
CREATE_ACTION(SearchLibraryAction, gt("search-in-library"));
|
||||
SET_SHORTCUT(SearchLibraryAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_R));
|
||||
HIDE_ACTION(SearchLibraryAction);
|
||||
|
||||
CREATE_ACTION(FindInPageAction, tr("Find in page"));
|
||||
CREATE_ACTION(FindInPageAction, gt("find-in-page"));
|
||||
mpa_actions[FindInPageAction]->setShortcuts({QKeySequence::Find, Qt::Key_F3});
|
||||
connect(mpa_actions[FindInPageAction], &QAction::triggered,
|
||||
this, [=]() { mp_tabWidget->openFindInPageBar(); });
|
||||
|
||||
CREATE_ACTION_ICON(ToggleFullscreenAction, "full-screen-enter", tr("Set fullScreen"));
|
||||
CREATE_ACTION_ICON(ToggleFullscreenAction, "full-screen-enter", gt("set-fullscreen"));
|
||||
SET_SHORTCUT(ToggleFullscreenAction, QKeySequence::FullScreen);
|
||||
connect(mpa_actions[ToggleFullscreenAction], &QAction::toggled,
|
||||
this, [=](bool checked) {
|
||||
auto action = mpa_actions[ToggleFullscreenAction];
|
||||
action->setIcon(
|
||||
QIcon(checked ? ":/icons/full-screen-exit.svg" : ":/icons/full-screen-enter.svg"));
|
||||
action->setText(checked ? tr("Quit fullScreen") : tr("Set fullScreen"));
|
||||
action->setText(checked ? gt("quit-fullscreen") : gt("set-fullscreen"));
|
||||
});
|
||||
mpa_actions[ToggleFullscreenAction]->setCheckable(true);
|
||||
|
||||
CREATE_ACTION(ToggleTOCAction, tr("Table of content"));
|
||||
CREATE_ACTION(ToggleTOCAction, gt("table-of-content"));
|
||||
SET_SHORTCUT(ToggleTOCAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_1));
|
||||
HIDE_ACTION(ToggleTOCAction);
|
||||
|
||||
CREATE_ACTION_ICON(ToggleReadingListAction, "reading-list" ,tr("Reading list"));
|
||||
CREATE_ACTION_ICON(ToggleReadingListAction, "reading-list" ,gt("reading-list"));
|
||||
SET_SHORTCUT(ToggleReadingListAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_2));
|
||||
connect(mpa_actions[ToggleReadingListAction], &QAction::triggered,
|
||||
this, [=]() { toggleSideBar(READINGLIST_BAR); });
|
||||
@ -350,37 +354,37 @@ void KiwixApp::createAction()
|
||||
QIcon((type == READINGLIST_BAR) ? ":/icons/reading-list-active.svg" : ":/icons/reading-list.svg"));
|
||||
});
|
||||
|
||||
CREATE_ACTION(ZoomInAction, tr("Zoom in"));
|
||||
CREATE_ACTION(ZoomInAction, gt("zoom-in"));
|
||||
SET_SHORTCUT(ZoomInAction, QKeySequence::ZoomIn);
|
||||
|
||||
CREATE_ACTION(ZoomOutAction, tr("Zoom out"));
|
||||
CREATE_ACTION(ZoomOutAction, gt("zoom-out"));
|
||||
SET_SHORTCUT(ZoomOutAction, QKeySequence::ZoomOut);
|
||||
|
||||
CREATE_ACTION(ZoomResetAction, tr("Zoom reset"));
|
||||
CREATE_ACTION(ZoomResetAction, gt("zoom-reset"));
|
||||
SET_SHORTCUT(ZoomResetAction, QKeySequence(Qt::CTRL+Qt::Key_0));
|
||||
|
||||
CREATE_ACTION(HelpAction, tr("Help"));
|
||||
CREATE_ACTION(HelpAction, gt("help"));
|
||||
SET_SHORTCUT(HelpAction, QKeySequence::HelpContents);
|
||||
HIDE_ACTION(HelpAction);
|
||||
|
||||
CREATE_ACTION(FeedbackAction, tr("Feedback"));
|
||||
CREATE_ACTION(FeedbackAction, gt("feedback"));
|
||||
HIDE_ACTION(FeedbackAction);
|
||||
|
||||
CREATE_ACTION(ReportBugAction, tr("Repost a bug"));
|
||||
CREATE_ACTION(ReportBugAction, gt("report-a-bug"));
|
||||
HIDE_ACTION(ReportBugAction);
|
||||
|
||||
CREATE_ACTION(RequestFeatureAction, tr("Request a feature"));
|
||||
CREATE_ACTION(RequestFeatureAction, gt("request-a-feature"));
|
||||
HIDE_ACTION(RequestFeatureAction);
|
||||
|
||||
CREATE_ACTION(AboutAction, tr("About Kiwix"));
|
||||
CREATE_ACTION(AboutAction, gt("about-kiwix"));
|
||||
|
||||
CREATE_ACTION_ICON(SettingAction, "settings", tr("Settings"));
|
||||
CREATE_ACTION_ICON(SettingAction, "settings", gt("settings"));
|
||||
SET_SHORTCUT(SettingAction, QKeySequence(Qt::Key_F12));
|
||||
|
||||
CREATE_ACTION_ICON(DonateAction, "donate", tr("Donate to support Kiwix"));
|
||||
CREATE_ACTION_ICON(DonateAction, "donate", gt("donate-to-support-kiwix"));
|
||||
SET_SHORTCUT(DonateAction, QKeySequence(Qt::CTRL+Qt::Key_D));
|
||||
|
||||
CREATE_ACTION_ICON(ExitAction, "exit", tr("Exit"));
|
||||
CREATE_ACTION_ICON(ExitAction, "exit", gt("exit"));
|
||||
SET_SHORTCUT(ExitAction, QKeySequence::Quit);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "kprofile.h"
|
||||
#include "urlschemehandler.h"
|
||||
#include "settingsmanager.h"
|
||||
#include "translation.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QErrorMessage>
|
||||
@ -77,6 +78,7 @@ public:
|
||||
kiwix::KiwixServe* getLocalServer() { return mp_server; }
|
||||
SettingsManager* getSettingsManager() { return &m_settingsManager; };
|
||||
SideBarType getSideType() { return m_currentSideType; }
|
||||
QString getText(const QString &key) { return m_translation.getText(key); };
|
||||
|
||||
bool isCurrentArticleBookmarked();
|
||||
|
||||
@ -110,10 +112,13 @@ private:
|
||||
SideBarType m_currentSideType;
|
||||
QErrorMessage* mp_errorDialog;
|
||||
kiwix::KiwixServe* mp_server;
|
||||
Translation m_translation;
|
||||
|
||||
QAction* mpa_actions[MAX_ACTION];
|
||||
|
||||
QString findLibraryDirectory();
|
||||
};
|
||||
|
||||
QString gt(const QString &key);
|
||||
|
||||
#endif // KIWIXAPP_H
|
||||
|
@ -17,7 +17,7 @@ void KProfile::startDownload(QWebEngineDownloadItem* download)
|
||||
{
|
||||
QString defaultFileName = download->url().fileName();
|
||||
QString fileName = QFileDialog::getSaveFileName(KiwixApp::instance()->getMainWindow(),
|
||||
tr("Save File as"), defaultFileName);
|
||||
gt("save-file-as-window-title"), defaultFileName);
|
||||
if (fileName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@ -33,6 +33,6 @@ void KProfile::startDownload(QWebEngineDownloadItem* download)
|
||||
void KProfile::downloadFinished()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("The document has been downloaded."));
|
||||
msgBox.setText(gt("download-finished-message"));
|
||||
msgBox.exec();
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ MainMenu::MainMenu(QWidget *parent) :
|
||||
ADD_ACTION(PrintAction);
|
||||
addSeparator();
|
||||
|
||||
m_fileMenu.setTitle(tr("File"));
|
||||
m_fileMenu.setTitle(gt("file"));
|
||||
m_fileMenu.ADD_ACTION(NewTabAction);
|
||||
m_fileMenu.ADD_ACTION(CloseTabAction);
|
||||
m_fileMenu.ADD_ACTION(ReopenClosedTabAction);
|
||||
@ -31,13 +31,13 @@ MainMenu::MainMenu(QWidget *parent) :
|
||||
|
||||
addMenu(&m_fileMenu);
|
||||
|
||||
m_editMenu.setTitle(tr("Edit"));
|
||||
m_editMenu.setTitle(gt("edit"));
|
||||
m_editMenu.ADD_ACTION(SearchArticleAction);
|
||||
m_editMenu.ADD_ACTION(SearchLibraryAction);
|
||||
m_editMenu.ADD_ACTION(FindInPageAction);
|
||||
addMenu(&m_editMenu);
|
||||
|
||||
m_viewMenu.setTitle(tr("View"));
|
||||
m_viewMenu.setTitle(gt("view"));
|
||||
m_viewMenu.ADD_ACTION(ToggleFullscreenAction);
|
||||
m_viewMenu.ADD_ACTION(ToggleTOCAction);
|
||||
m_viewMenu.ADD_ACTION(ToggleReadingListAction);
|
||||
@ -46,11 +46,11 @@ MainMenu::MainMenu(QWidget *parent) :
|
||||
m_viewMenu.ADD_ACTION(ZoomResetAction);
|
||||
addMenu(&m_viewMenu);
|
||||
|
||||
m_toolsMenu.setTitle(tr("Tools"));
|
||||
m_toolsMenu.setTitle(gt("tools"));
|
||||
// m_toolsMenu.addAction();
|
||||
// addMenu(&m_toolsMenu);
|
||||
|
||||
m_helpMenu.setTitle(tr("Help"));
|
||||
m_helpMenu.setTitle(gt("help"));
|
||||
m_helpMenu.ADD_ACTION(HelpAction);
|
||||
m_helpMenu.ADD_ACTION(FeedbackAction);
|
||||
m_helpMenu.ADD_ACTION(ReportBugAction);
|
||||
|
@ -32,7 +32,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
if (!title.isEmpty() && !title.startsWith("zim://"))
|
||||
setWindowTitle(title + " - Kiwix");
|
||||
else
|
||||
setWindowTitle(tr("Library") + " - Kiwix");
|
||||
setWindowTitle(gt("window-title"));
|
||||
});
|
||||
addAction(app->getAction(KiwixApp::OpenHomePageAction));
|
||||
#if !SYSTEMTITLEBAR
|
||||
|
@ -62,7 +62,7 @@ SearchBar::SearchBar(QWidget *parent) :
|
||||
m_completer(&m_completionModel, this),
|
||||
m_button(this)
|
||||
{
|
||||
setPlaceholderText(tr("Search"));
|
||||
setPlaceholderText(gt("search"));
|
||||
m_completer.setCompletionMode(QCompleter::UnfilteredPopupCompletion);
|
||||
m_completer.setCaseSensitivity(Qt::CaseInsensitive);
|
||||
setCompleter(&m_completer);
|
||||
|
@ -85,7 +85,7 @@ void SettingsManager::resetDownloadDir()
|
||||
void SettingsManager::browseDownloadDir()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(KiwixApp::instance()->getMainWindow(),
|
||||
tr("Browse Directory"),
|
||||
gt("browse-directory"),
|
||||
QString(),
|
||||
QFileDialog::ShowDirsOnly);
|
||||
emit(downloadDirChanged(dir));
|
||||
|
@ -52,7 +52,7 @@ TabBar::TabBar(QWidget *parent) :
|
||||
m_settingsIndex = index;
|
||||
auto view = KiwixApp::instance()->getSettingsManager()->getView();
|
||||
mp_stackedWidget->insertWidget(index, view);
|
||||
insertTab(index,QIcon(":/icons/settings.svg"), tr("Settings"));
|
||||
insertTab(index,QIcon(":/icons/settings.svg"), gt("settings"));
|
||||
QToolButton *tb = new QToolButton(this);
|
||||
tb->setDefaultAction(KiwixApp::instance()->getAction(KiwixApp::CloseTabAction));
|
||||
setTabButton(index, QTabBar::RightSide, tb);
|
||||
|
@ -12,8 +12,8 @@ TopWidget::TopWidget(QWidget *parent) :
|
||||
{
|
||||
mp_historyBackAction = new QAction(this);
|
||||
mp_historyBackAction->setIcon(QIcon(":/icons/back.svg"));
|
||||
mp_historyBackAction->setText(tr("back"));
|
||||
mp_historyBackAction->setToolTip(tr("back"));
|
||||
mp_historyBackAction->setText(gt("back"));
|
||||
mp_historyBackAction->setToolTip(gt("back"));
|
||||
mp_historyBackAction->setEnabled(false);
|
||||
connect(mp_historyBackAction, &QAction::triggered, [](){
|
||||
KiwixApp::instance()->getTabWidget()->triggerWebPageAction(QWebEnginePage::Back);
|
||||
@ -22,8 +22,8 @@ TopWidget::TopWidget(QWidget *parent) :
|
||||
widgetForAction(mp_historyBackAction)->setObjectName("backButton");
|
||||
mp_historyForwardAction = new QAction(this);
|
||||
mp_historyForwardAction->setIcon(QIcon(":/icons/forward.svg"));
|
||||
mp_historyForwardAction->setText(tr("forward"));
|
||||
mp_historyForwardAction->setToolTip(tr("forward"));
|
||||
mp_historyForwardAction->setText(gt("forward"));
|
||||
mp_historyForwardAction->setToolTip(gt("forward"));
|
||||
mp_historyForwardAction->setEnabled(false);
|
||||
connect(mp_historyForwardAction, &QAction::triggered, [](){
|
||||
KiwixApp::instance()->getTabWidget()->triggerWebPageAction(QWebEnginePage::Forward);
|
||||
|
Loading…
x
Reference in New Issue
Block a user