From b71fc67032a48de351fc540d7cd3e64673831327 Mon Sep 17 00:00:00 2001 From: Thierry Date: Tue, 21 Aug 2018 09:38:57 +0200 Subject: [PATCH 01/10] Added translation mechanism, and added French translation. --- kiwix-desktop.pro | 4 + locales/kiwix-desktop_fr.ts | 243 ++++++++++++++++++++++++++++++++++++ src/kiwixapp.cpp | 59 ++++----- src/library.cpp | 4 +- src/main.cpp | 9 ++ src/mainmenu.cpp | 13 +- src/searchbar.cpp | 3 +- src/topwidget.cpp | 9 +- 8 files changed, 303 insertions(+), 41 deletions(-) create mode 100644 locales/kiwix-desktop_fr.ts diff --git a/kiwix-desktop.pro b/kiwix-desktop.pro index e7f5828..af28b3a 100644 --- a/kiwix-desktop.pro +++ b/kiwix-desktop.pro @@ -85,6 +85,10 @@ isEmpty(PREFIX) { target.path = $$PREFIX/bin INSTALLS += target +TRANSLATIONS = locales/kiwix-desktop_fr.ts +CODECFORSRC = UTF-8 + +QT += widgets static { PKGCONFIG_OPTION = "--static" diff --git a/locales/kiwix-desktop_fr.ts b/locales/kiwix-desktop_fr.ts new file mode 100644 index 0000000..53a250f --- /dev/null +++ b/locales/kiwix-desktop_fr.ts @@ -0,0 +1,243 @@ + + + + + AboutDialog + + + About + A propos + + + + qrc:/texts/about.html + qrc:/texts/about.html + + + + KiwixApp + + + Open Zim + Ouvrir Zim + + + + Local Kiwix Server + Serveur local Kiwix + + + + Random Article + Article aléatoire + + + + Print + Imprimer + + + + New tab + Nouvel onglet + + + + Close tab + Fermer l'onglet + + + + Reopen closed tab + Rouvrir l'onglet fermé + + + + Browse library + Parcourir la bibliothèque + + + + Open file + Ouvrir un ficher + + + + Open recent + Fichiers récemment ouverts + + + + Save page as ... + Enregister sous... + + + + Search article + Chercher un article + + + + Search in library + Chercher dans la bibliothèque + + + + Find in page + Chercher dans la page + + + + Find next + Trouver le suivant + + + + Find previous + Trouver le précédent + + + + + Set fullScreen + Mode plein écran + + + + Quit fullScreen + Quitter le pein écran + + + + Table of content + Table des matières + + + + Reading list + Liste de lecture + + + + Zoom in + Zoom + + + + + Zoom out + Zoom - + + + + Zoom reset + Réinitialisation du zoom + + + + Help + Aide + + + + Feedback + Retour d'information + + + + Repost a bug + Déclarer un bogue + + + + Request a feature + Demander une nouvelle fonctionnalité + + + + About Kiwix + A propos de Kiwix + + + + Settings + Paramètres + + + + Donate to support Kiwix + Faire un don pour soutenir Kiwix + + + + Exit + Quitter + + + + Library + + + Opening + Ouverture + + + + MainMenu + + + File + Fichier + + + + Edit + Édition + + + + View + Affichage + + + + Tools + Outils + + + + Help + Aide + + + + MainWindow + + + MainWindow + MainWindow + + + + SearchBar + + + Search + Recherche + + + + TopWidget + + + + back + Précédent + + + + + forward + Suivant + + + diff --git a/src/kiwixapp.cpp b/src/kiwixapp.cpp index 851f334..e0e39e7 100644 --- a/src/kiwixapp.cpp +++ b/src/kiwixapp.cpp @@ -1,6 +1,7 @@ #include "kiwixapp.h" #include "zim/error.h" +#include #include #include #include @@ -83,7 +84,7 @@ void KiwixApp::openZimFile(const QString &zimfile) if (_zimfile.isEmpty()) { _zimfile = QFileDialog::getOpenFileName( getMainWindow(), - "Open Zim", + tr("Open Zim"), QString(), "ZimFile (*.zim*)"); } @@ -161,109 +162,109 @@ QAction *KiwixApp::getAction(KiwixApp::Actions action) void KiwixApp::createAction() { - CREATE_ACTION_ICON(KiwixServeAction, "share", "Local Kiwix Server"); + CREATE_ACTION_ICON(KiwixServeAction, "share", tr("Local Kiwix Server")); SET_SHORTCUT(KiwixServeAction, QKeySequence(Qt::CTRL+Qt::Key_I)); HIDE_ACTION(KiwixServeAction); - CREATE_ACTION_ICON(RandomArticleAction, "random", "Random Article"); + CREATE_ACTION_ICON(RandomArticleAction, "random", tr("Random Article")); SET_SHORTCUT(RandomArticleAction, QKeySequence(Qt::CTRL+Qt::Key_R)); connect(mpa_actions[RandomArticleAction], &QAction::triggered, this, [=]() { this->openRandomUrl(); }); - CREATE_ACTION_ICON(PrintAction, "print", "Print"); + CREATE_ACTION_ICON(PrintAction, "print", tr("Print")); SET_SHORTCUT(PrintAction, QKeySequence::Print); connect(mpa_actions[PrintAction], &QAction::triggered, this, &KiwixApp::printPage); - CREATE_ACTION(NewTabAction, "New tab"); + CREATE_ACTION(NewTabAction, tr("New tab")); SET_SHORTCUT(NewTabAction, QKeySequence::AddTab); - CREATE_ACTION(CloseTabAction, "Close tab"); + CREATE_ACTION(CloseTabAction, tr("Close tab")); SET_SHORTCUT(CloseTabAction, QKeySequence::Close); - CREATE_ACTION(ReopenClosedTabAction, "Reopen closed tab"); + CREATE_ACTION(ReopenClosedTabAction, tr("Reopen closed tab")); SET_SHORTCUT(ReopenClosedTabAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_T)); HIDE_ACTION(ReopenClosedTabAction); - CREATE_ACTION(BrowseLibraryAction, "Browse library"); + CREATE_ACTION(BrowseLibraryAction, tr("Browse library")); SET_SHORTCUT(BrowseLibraryAction, QKeySequence(Qt::CTRL+Qt::Key_E)); HIDE_ACTION(BrowseLibraryAction); - CREATE_ACTION(OpenFileAction, "Open file"); + CREATE_ACTION(OpenFileAction, tr("Open file")); SET_SHORTCUT(OpenFileAction, QKeySequence::Open); connect(mpa_actions[OpenFileAction], &QAction::triggered, this, [=]() { openZimFile(); }); - CREATE_ACTION(OpenRecentAction, "Open recent"); + CREATE_ACTION(OpenRecentAction, tr("Open recent")); HIDE_ACTION(OpenRecentAction); - CREATE_ACTION(SavePageAsAction, "Save page as ..."); + CREATE_ACTION(SavePageAsAction, tr("Save page as ...")); SET_SHORTCUT(SavePageAsAction, QKeySequence::SaveAs); HIDE_ACTION(SavePageAsAction); - CREATE_ACTION(SearchArticleAction, "Search article"); + CREATE_ACTION(SearchArticleAction, tr("Search article")); SET_SHORTCUT(SearchArticleAction, QKeySequence(Qt::CTRL+Qt::Key_L)); HIDE_ACTION(SearchArticleAction); - CREATE_ACTION(SearchLibraryAction, "Search in library"); + CREATE_ACTION(SearchLibraryAction, tr("Search in library")); SET_SHORTCUT(SearchLibraryAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_R)); HIDE_ACTION(SearchLibraryAction); - CREATE_ACTION(FindInPageAction, "Find in page"); + CREATE_ACTION(FindInPageAction, tr("Find in page")); SET_SHORTCUT(FindInPageAction, QKeySequence::Find); - CREATE_ACTION_ICON(ToggleFullscreenAction, "full-screen-enter", "Set fullScreen"); + CREATE_ACTION_ICON(ToggleFullscreenAction, "full-screen-enter", tr("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 ? "Quit fullScreen" : "Set fullScreen"); + action->setText(checked ? tr("Quit fullScreen") : tr("Set fullScreen")); }); mpa_actions[ToggleFullscreenAction]->setCheckable(true); - CREATE_ACTION(ToggleTOCAction, "Table of content"); + CREATE_ACTION(ToggleTOCAction, tr("Table of content")); SET_SHORTCUT(ToggleTOCAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_1)); HIDE_ACTION(ToggleTOCAction); - CREATE_ACTION(ToggleReadingListAction, "Reading list"); + CREATE_ACTION(ToggleReadingListAction, tr("Reading list")); SET_SHORTCUT(ToggleReadingListAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_2)); HIDE_ACTION(ToggleReadingListAction); - CREATE_ACTION(ZoomInAction, "Zoom in"); + CREATE_ACTION(ZoomInAction, tr("Zoom in")); SET_SHORTCUT(ZoomInAction, QKeySequence::ZoomIn); - CREATE_ACTION(ZoomOutAction, "Zoom out"); + CREATE_ACTION(ZoomOutAction, tr("Zoom out")); SET_SHORTCUT(ZoomOutAction, QKeySequence::ZoomOut); - CREATE_ACTION(ZoomResetAction, "Zoom reset"); + CREATE_ACTION(ZoomResetAction, tr("Zoom reset")); SET_SHORTCUT(ZoomResetAction, QKeySequence(Qt::CTRL+Qt::Key_0)); - CREATE_ACTION(HelpAction, "Help"); + CREATE_ACTION(HelpAction, tr("Help")); SET_SHORTCUT(HelpAction, QKeySequence::HelpContents); HIDE_ACTION(HelpAction); - CREATE_ACTION(FeedbackAction, "Feedback"); + CREATE_ACTION(FeedbackAction, tr("Feedback")); HIDE_ACTION(FeedbackAction); - CREATE_ACTION(ReportBugAction, "Repost a bug"); + CREATE_ACTION(ReportBugAction, tr("Repost a bug")); HIDE_ACTION(ReportBugAction); - CREATE_ACTION(RequestFeatureAction, "Request a feature"); + CREATE_ACTION(RequestFeatureAction, tr("Request a feature")); HIDE_ACTION(RequestFeatureAction); - CREATE_ACTION(AboutAction, "About Kiwix"); + CREATE_ACTION(AboutAction, tr("About Kiwix")); - CREATE_ACTION_ICON(SettingAction, "settings", "Settings"); + CREATE_ACTION_ICON(SettingAction, "settings", tr("Settings")); SET_SHORTCUT(SettingAction, QKeySequence::Preferences); HIDE_ACTION(SettingAction); - CREATE_ACTION_ICON(DonateAction, "donate", "Donate to support Kiwix"); + CREATE_ACTION_ICON(DonateAction, "donate", tr("Donate to support Kiwix")); //SET_SHORTCUT(DonateAction, QKeySequence(Qt::CTRL+Qt::Key_BracketLeft+Qt::Key_3)); HIDE_ACTION(DonateAction); - CREATE_ACTION_ICON(ExitAction, "exit", "Exit"); + CREATE_ACTION_ICON(ExitAction, "exit", tr("Exit")); SET_SHORTCUT(ExitAction, QKeySequence::Quit); } diff --git a/src/library.cpp b/src/library.cpp index 1227ee6..c84d446 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -1,4 +1,6 @@ #include "library.h" + +#include #include Library::Library() @@ -15,7 +17,7 @@ QString Library::openBook(const QString &zimPath) if(QString::fromStdString(it->second->getZimFilePath()) == zimPath) return it->first; } - qInfo() << "Opening" << zimPath; + qInfo() << tr("Opening") << zimPath; auto zimPath_ = zimPath.toStdString(); auto reader = std::shared_ptr(new kiwix::Reader(zimPath_)); auto id = QString::fromStdString(reader->getId() + ".zim"); diff --git a/src/main.cpp b/src/main.cpp index defba0b..1b13bfd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,15 @@ int main(int argc, char *argv[]) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); KiwixApp a(argc, argv); + QTranslator qtTranslator; + qtTranslator.load("qt_" + QLocale::system().name(), + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + a.installTranslator(&qtTranslator); + + QTranslator myappTranslator; + myappTranslator.load("kiwix-desktop_" + QLocale::system().name()); + a.installTranslator(&myappTranslator); + QCommandLineParser parser; parser.addPositionalArgument("zimfile", "The zim file"); diff --git a/src/mainmenu.cpp b/src/mainmenu.cpp index 442d0ac..0e2477c 100644 --- a/src/mainmenu.cpp +++ b/src/mainmenu.cpp @@ -1,5 +1,6 @@ -#include "mainmenu.h" +#include +#include "mainmenu.h" #include "kiwixapp.h" #define ADD_ACTION(ID) addAction(app->getAction(KiwixApp::ID)); @@ -14,7 +15,7 @@ MainMenu::MainMenu(QWidget *parent) : ADD_ACTION(PrintAction); addSeparator(); - m_fileMenu.setTitle("File"); + m_fileMenu.setTitle(tr("File")); m_fileMenu.ADD_ACTION(NewTabAction); m_fileMenu.ADD_ACTION(CloseTabAction); m_fileMenu.ADD_ACTION(ReopenClosedTabAction); @@ -24,13 +25,13 @@ MainMenu::MainMenu(QWidget *parent) : m_fileMenu.ADD_ACTION(SavePageAsAction); addMenu(&m_fileMenu); - m_editMenu.setTitle("Edit"); + m_editMenu.setTitle(tr("Edit")); m_editMenu.ADD_ACTION(SearchArticleAction); m_editMenu.ADD_ACTION(SearchLibraryAction); m_editMenu.ADD_ACTION(FindInPageAction); addMenu(&m_editMenu); - m_viewMenu.setTitle("View"); + m_viewMenu.setTitle(tr("View")); m_viewMenu.ADD_ACTION(ToggleFullscreenAction); m_viewMenu.ADD_ACTION(ToggleTOCAction); m_viewMenu.ADD_ACTION(ToggleReadingListAction); @@ -39,11 +40,11 @@ MainMenu::MainMenu(QWidget *parent) : m_viewMenu.ADD_ACTION(ZoomResetAction); addMenu(&m_viewMenu); - m_toolsMenu.setTitle("Tools"); + m_toolsMenu.setTitle(tr("Tools")); // m_toolsMenu.addAction(); // addMenu(&m_toolsMenu); - m_helpMenu.setTitle("Help"); + m_helpMenu.setTitle(tr("Help")); m_helpMenu.ADD_ACTION(HelpAction); m_helpMenu.ADD_ACTION(FeedbackAction); m_helpMenu.ADD_ACTION(ReportBugAction); diff --git a/src/searchbar.cpp b/src/searchbar.cpp index c6ffd38..6d045c4 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -1,5 +1,6 @@ #include "searchbar.h" +#include #include #include @@ -9,7 +10,7 @@ SearchBar::SearchBar(QWidget *parent) : QLineEdit(parent), m_completer(&m_completionModel, this) { - setPlaceholderText("Search"); + setPlaceholderText(tr("Search")); m_completer.setCompletionMode(QCompleter::UnfilteredPopupCompletion); setCompleter(&m_completer); connect(this, &QLineEdit::textEdited, this, &SearchBar::updateCompletion); diff --git a/src/topwidget.cpp b/src/topwidget.cpp index 4ccf7e0..942cd69 100644 --- a/src/topwidget.cpp +++ b/src/topwidget.cpp @@ -4,6 +4,7 @@ #include "kiwixapp.h" #include "mainmenu.h" +#include #include #include @@ -12,16 +13,16 @@ TopWidget::TopWidget(QWidget *parent) : { mp_historyBackAction = new QAction(this); mp_historyBackAction->setIcon(QIcon(":/icons/back.svg")); - mp_historyBackAction->setText("back"); - mp_historyBackAction->setToolTip("back"); + mp_historyBackAction->setText(tr("back")); + mp_historyBackAction->setToolTip(tr("back")); connect(mp_historyBackAction, &QAction::triggered, [this](){ KiwixApp::instance()->getTabWidget()->triggerWebPageAction(QWebEnginePage::Back); }); addAction(mp_historyBackAction); mp_historyForwardAction = new QAction(this); mp_historyForwardAction->setIcon(QIcon(":/icons/forward.svg")); - mp_historyForwardAction->setText("forward"); - mp_historyForwardAction->setToolTip("forward"); + mp_historyForwardAction->setText(tr("forward")); + mp_historyForwardAction->setToolTip(tr("forward")); connect(mp_historyForwardAction, &QAction::triggered, [this](){ KiwixApp::instance()->getTabWidget()->triggerWebPageAction(QWebEnginePage::Forward); }); From 3d930e5bd8b920892262388a3ecb589488c5f2fd Mon Sep 17 00:00:00 2001 From: Thierry Date: Tue, 21 Aug 2018 14:29:27 +0200 Subject: [PATCH 02/10] Add build locale. --- locales/kiwix-desktop_fr.qm | Bin 0 -> 3381 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 locales/kiwix-desktop_fr.qm diff --git a/locales/kiwix-desktop_fr.qm b/locales/kiwix-desktop_fr.qm new file mode 100644 index 0000000000000000000000000000000000000000..7494cb15679606451eab2bf15a7a00918edf6952 GIT binary patch literal 3381 zcmai0TWl0n82*>eUfSJWsF)f;U}z8!vEVH+sEGwyG2BYGSW*&ocK7V|gz3yMGuu`Y zA<6^z<^zfdnvn3~lTRi@@DihuOAMHJOB79vCT(KE14@kH!S6q_JKgO}vCYoR&Yu7K zzyJF$=R9@3bl;VmXWsmJ<+4v-I{WdB%|wZPq+QU6TK^^O8t#c(q+P$CsOKZ6AGH z`_?a0CpU7OPo_Q-?}Fdb)YWU__!?{>TV@ptffz5UL}VZ48$^YE`H;MW3J z_F@Z=x~QLYa>ykcSDU;HUQ!C5WPib~`e{66)zemKn06(>M(gMx42ragHjqz(rg8P~ zY)}CZRebBCaa+QZ`_|SW8r(}a{|K>+~~BOBu(Kn9l{3O z^zCv=PBU0WJ@q?|BKimoffQ3^S}rVIpqO~4gQ~>G#MK7XahgF;RT3d`$7a`_@`P^6 zf@`=hN5PlVAV|50lCKQA22d7N@Fd6&fm*kiHgJ5S5XE=~7>1(7;ZZ8xG#UZ>*se0%Zn;C>4z2foQzzXbYrfy^6Iv$7=x2Qwnlo9DJ`dBqBE`t&%P+ z-7zX63b~3#0LKDNDqv0oi|MH#Clz=@G8CAFGK?avT>y!@V-|#GRTWwdsclzijw>dm zUG<`f8C0@lt56$ln=qZ|!qt>l?A(b**A3+)fijI2@iBLh+6OS1bB4-t{D~iI3Npu%I2Lw(lLSppLE;;1NIE!`7 zJp;c%kvXvDX3$lExLj-@R_C6o^!0MpH1kDQ2rH@-4?0)1PqBu_`JM#|w;Ol*T;X&K z8&=7l(ED9q7UKldX$MR^m~!<8^O8vx@rFxk4k|Y+jFPk}7;RpRI_uH!K|9q`KX0-D zzRapYyV)?>#lynpk|^@9E5(;oFKtyi@c;%PeCjig_l*i@Hj#8}&({sTP_0Cz+Xg5u z1Rfn6YaNPXw`%kS#0=8Jv&vFRs7Zxq7Me$3Qve66LU}9;!>_tAMY)OwV9V4iq1Nm< z7|G4n9!7gmS|tE!9;vLi1Hw>YjF3su3U7{K`h z_WyRi#Wg1wxeIQ7I_-p}L6td5<%QY+l<(dJOKO|6fppFwW|nuZlQS^)QLHi3l_x(R zIf5KB7akJz9cgABP}hi2FokZH^`dS0v2!6uV+hIygia5Jny1HX^qq|9-^TS1h3hkF zeeLYjyq9i7Yt165yp3~mgDUiJukE35TtXY@bSNMag0?A8S9l_(W4mh;m)l@|v!{6y zLO-s(^p4;xqs~ShbQ!(^9*w)VHc+Y^19lqH+9|ARZF$o?4vA@l_3_=b{BAp6)54tM z&f%L4Sx=7Gwi%?nX>~UyW*Ps%&d_{L(4LoKO0`&%$r4m5AF(VNRaZV Date: Wed, 22 Aug 2018 12:00:51 +0200 Subject: [PATCH 03/10] Partial functioning of translations --- kiwix-desktop.pro | 10 +++++++--- {locales => resources/i18n}/kiwix-desktop_fr.qm | Bin {locales => resources/i18n}/kiwix-desktop_fr.ts | 2 +- resources/translations.qrc | 5 +++++ src/library.cpp | 4 ++-- src/main.cpp | 9 ++++++++- 6 files changed, 23 insertions(+), 7 deletions(-) rename {locales => resources/i18n}/kiwix-desktop_fr.qm (100%) rename {locales => resources/i18n}/kiwix-desktop_fr.ts (99%) create mode 100644 resources/translations.qrc diff --git a/kiwix-desktop.pro b/kiwix-desktop.pro index af28b3a..e90b727 100644 --- a/kiwix-desktop.pro +++ b/kiwix-desktop.pro @@ -6,6 +6,7 @@ QT += core gui QT += webenginewidgets +QT += widgets qml quick CONFIG += link_pkgconfig @@ -85,10 +86,9 @@ isEmpty(PREFIX) { target.path = $$PREFIX/bin INSTALLS += target -TRANSLATIONS = locales/kiwix-desktop_fr.ts +TRANSLATIONS = "resources/i18n/kiwix-desktop_fr.ts" CODECFORSRC = UTF-8 -QT += widgets static { PKGCONFIG_OPTION = "--static" @@ -117,4 +117,8 @@ QMAKE_CFLAGS += $$PKGCONFIG_CFLAGS LIBS += $$system(pkg-config --libs $$PKGCONFIG_OPTION kiwix) RESOURCES += \ - resources/kiwix.qrc + resources/kiwix.qrc \ + resources/translations.qrc + +system($$QMAKE_LUPDATE -locations relative -no-ui-lines $$_PRO_FILE_) +system($$QMAKE_LRELEASE $$_PRO_FILE_) diff --git a/locales/kiwix-desktop_fr.qm b/resources/i18n/kiwix-desktop_fr.qm similarity index 100% rename from locales/kiwix-desktop_fr.qm rename to resources/i18n/kiwix-desktop_fr.qm diff --git a/locales/kiwix-desktop_fr.ts b/resources/i18n/kiwix-desktop_fr.ts similarity index 99% rename from locales/kiwix-desktop_fr.ts rename to resources/i18n/kiwix-desktop_fr.ts index 53a250f..191bfe2 100644 --- a/locales/kiwix-desktop_fr.ts +++ b/resources/i18n/kiwix-desktop_fr.ts @@ -1,6 +1,6 @@ - + AboutDialog diff --git a/resources/translations.qrc b/resources/translations.qrc new file mode 100644 index 0000000..5100ea5 --- /dev/null +++ b/resources/translations.qrc @@ -0,0 +1,5 @@ + + + i18n/kiwix-desktop_fr.qm + + diff --git a/src/library.cpp b/src/library.cpp index c84d446..2647839 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -1,6 +1,6 @@ #include "library.h" -#include +#include #include Library::Library() @@ -17,7 +17,7 @@ QString Library::openBook(const QString &zimPath) if(QString::fromStdString(it->second->getZimFilePath()) == zimPath) return it->first; } - qInfo() << tr("Opening") << zimPath; + qInfo() << QObject::tr("Opening") << zimPath; auto zimPath_ = zimPath.toStdString(); auto reader = std::shared_ptr(new kiwix::Reader(zimPath_)); auto id = QString::fromStdString(reader->getId() + ".zim"); diff --git a/src/main.cpp b/src/main.cpp index 1b13bfd..107a9b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,7 @@ #include "kiwixapp.h" +#include +#include #include #include @@ -8,13 +10,18 @@ int main(int argc, char *argv[]) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); KiwixApp a(argc, argv); + // format systems language + QString defaultLocale = QLocale::system().name(); // e.g. "de_DE" + defaultLocale.truncate(defaultLocale.lastIndexOf('_')); // e.g. "de" + QLocale::setDefault(defaultLocale); + QTranslator qtTranslator; qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); a.installTranslator(&qtTranslator); QTranslator myappTranslator; - myappTranslator.load("kiwix-desktop_" + QLocale::system().name()); + myappTranslator.load(":/i18n/kiwix-desktop.qm"); a.installTranslator(&myappTranslator); QCommandLineParser parser; From 594ec511101796f8b1b51220a586b4e56002c35b Mon Sep 17 00:00:00 2001 From: Thierry Date: Wed, 22 Aug 2018 16:52:51 +0000 Subject: [PATCH 04/10] Return of the maintenair --- kiwix-desktop.pro | 8 ++---- src/kiwixapp.cpp | 72 +++++++++++++++++++++++++++-------------------- src/library.cpp | 3 +- src/main.cpp | 16 ----------- src/mainmenu.cpp | 12 ++++---- src/searchbar.cpp | 4 +-- src/topwidget.cpp | 10 +++---- 7 files changed, 59 insertions(+), 66 deletions(-) diff --git a/kiwix-desktop.pro b/kiwix-desktop.pro index e90b727..786c50e 100644 --- a/kiwix-desktop.pro +++ b/kiwix-desktop.pro @@ -6,7 +6,6 @@ QT += core gui QT += webenginewidgets -QT += widgets qml quick CONFIG += link_pkgconfig @@ -80,16 +79,15 @@ FORMS += \ ui/about.ui \ src/tocsidebar.ui +TRANSLATIONS = "resources/i18n/kiwix-desktop_fr.ts" +CODECFORSRC = UTF-8 + isEmpty(PREFIX) { PREFIX = /usr/local } target.path = $$PREFIX/bin INSTALLS += target -TRANSLATIONS = "resources/i18n/kiwix-desktop_fr.ts" -CODECFORSRC = UTF-8 - - static { PKGCONFIG_OPTION = "--static" } diff --git a/src/kiwixapp.cpp b/src/kiwixapp.cpp index e0e39e7..956addc 100644 --- a/src/kiwixapp.cpp +++ b/src/kiwixapp.cpp @@ -1,7 +1,10 @@ #include "kiwixapp.h" #include "zim/error.h" -#include +#include +#include +#include +#include #include #include #include @@ -13,6 +16,15 @@ KiwixApp::KiwixApp(int& argc, char *argv[]) : QApplication(argc, argv) { + QTranslator qtTranslator; + qtTranslator.load("qt_" + QLocale::system().name(), + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + installTranslator(&qtTranslator); + + QTranslator myappTranslator; + myappTranslator.load(":/i18n/kiwix-desktop.qm"); + installTranslator(&myappTranslator); + auto icon = QIcon(); icon.addFile(":/icons/kiwix/app_icon.svg"); setWindowIcon(icon); @@ -84,7 +96,7 @@ void KiwixApp::openZimFile(const QString &zimfile) if (_zimfile.isEmpty()) { _zimfile = QFileDialog::getOpenFileName( getMainWindow(), - tr("Open Zim"), + QObject::tr("Open Zim"), QString(), "ZimFile (*.zim*)"); } @@ -162,109 +174,109 @@ QAction *KiwixApp::getAction(KiwixApp::Actions action) void KiwixApp::createAction() { - CREATE_ACTION_ICON(KiwixServeAction, "share", tr("Local Kiwix Server")); + CREATE_ACTION_ICON(KiwixServeAction, "share", QObject::tr("Local Kiwix Server")); SET_SHORTCUT(KiwixServeAction, QKeySequence(Qt::CTRL+Qt::Key_I)); HIDE_ACTION(KiwixServeAction); - CREATE_ACTION_ICON(RandomArticleAction, "random", tr("Random Article")); + CREATE_ACTION_ICON(RandomArticleAction, "random", QObject::tr("Random Article")); SET_SHORTCUT(RandomArticleAction, QKeySequence(Qt::CTRL+Qt::Key_R)); connect(mpa_actions[RandomArticleAction], &QAction::triggered, this, [=]() { this->openRandomUrl(); }); - CREATE_ACTION_ICON(PrintAction, "print", tr("Print")); + CREATE_ACTION_ICON(PrintAction, "print", QObject::tr("Print")); SET_SHORTCUT(PrintAction, QKeySequence::Print); connect(mpa_actions[PrintAction], &QAction::triggered, this, &KiwixApp::printPage); - CREATE_ACTION(NewTabAction, tr("New tab")); + CREATE_ACTION(NewTabAction, QObject::tr("New tab")); SET_SHORTCUT(NewTabAction, QKeySequence::AddTab); - CREATE_ACTION(CloseTabAction, tr("Close tab")); + CREATE_ACTION(CloseTabAction, QObject::tr("Close tab")); SET_SHORTCUT(CloseTabAction, QKeySequence::Close); - CREATE_ACTION(ReopenClosedTabAction, tr("Reopen closed tab")); + CREATE_ACTION(ReopenClosedTabAction, QObject::tr("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, QObject::tr("Browse library")); SET_SHORTCUT(BrowseLibraryAction, QKeySequence(Qt::CTRL+Qt::Key_E)); HIDE_ACTION(BrowseLibraryAction); - CREATE_ACTION(OpenFileAction, tr("Open file")); + CREATE_ACTION(OpenFileAction, QObject::tr("Open file")); SET_SHORTCUT(OpenFileAction, QKeySequence::Open); connect(mpa_actions[OpenFileAction], &QAction::triggered, this, [=]() { openZimFile(); }); - CREATE_ACTION(OpenRecentAction, tr("Open recent")); + CREATE_ACTION(OpenRecentAction, QObject::tr("Open recent")); HIDE_ACTION(OpenRecentAction); - CREATE_ACTION(SavePageAsAction, tr("Save page as ...")); + CREATE_ACTION(SavePageAsAction, QObject::tr("Save page as ...")); SET_SHORTCUT(SavePageAsAction, QKeySequence::SaveAs); HIDE_ACTION(SavePageAsAction); - CREATE_ACTION(SearchArticleAction, tr("Search article")); + CREATE_ACTION(SearchArticleAction, QObject::tr("Search article")); SET_SHORTCUT(SearchArticleAction, QKeySequence(Qt::CTRL+Qt::Key_L)); HIDE_ACTION(SearchArticleAction); - CREATE_ACTION(SearchLibraryAction, tr("Search in library")); + CREATE_ACTION(SearchLibraryAction, QObject::tr("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, QObject::tr("Find in page")); SET_SHORTCUT(FindInPageAction, QKeySequence::Find); - CREATE_ACTION_ICON(ToggleFullscreenAction, "full-screen-enter", tr("Set fullScreen")); + CREATE_ACTION_ICON(ToggleFullscreenAction, "full-screen-enter", QObject::tr("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 ? QObject::tr("Quit fullScreen") : QObject::tr("Set fullScreen")); }); mpa_actions[ToggleFullscreenAction]->setCheckable(true); - CREATE_ACTION(ToggleTOCAction, tr("Table of content")); + CREATE_ACTION(ToggleTOCAction, QObject::tr("Table of content")); SET_SHORTCUT(ToggleTOCAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_1)); HIDE_ACTION(ToggleTOCAction); - CREATE_ACTION(ToggleReadingListAction, tr("Reading list")); + CREATE_ACTION(ToggleReadingListAction, QObject::tr("Reading list")); SET_SHORTCUT(ToggleReadingListAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_2)); HIDE_ACTION(ToggleReadingListAction); - CREATE_ACTION(ZoomInAction, tr("Zoom in")); + CREATE_ACTION(ZoomInAction, QObject::tr("Zoom in")); SET_SHORTCUT(ZoomInAction, QKeySequence::ZoomIn); - CREATE_ACTION(ZoomOutAction, tr("Zoom out")); + CREATE_ACTION(ZoomOutAction, QObject::tr("Zoom out")); SET_SHORTCUT(ZoomOutAction, QKeySequence::ZoomOut); - CREATE_ACTION(ZoomResetAction, tr("Zoom reset")); + CREATE_ACTION(ZoomResetAction, QObject::tr("Zoom reset")); SET_SHORTCUT(ZoomResetAction, QKeySequence(Qt::CTRL+Qt::Key_0)); - CREATE_ACTION(HelpAction, tr("Help")); + CREATE_ACTION(HelpAction, QObject::tr("Help")); SET_SHORTCUT(HelpAction, QKeySequence::HelpContents); HIDE_ACTION(HelpAction); - CREATE_ACTION(FeedbackAction, tr("Feedback")); + CREATE_ACTION(FeedbackAction, QObject::tr("Feedback")); HIDE_ACTION(FeedbackAction); - CREATE_ACTION(ReportBugAction, tr("Repost a bug")); + CREATE_ACTION(ReportBugAction, QObject::tr("Repost a bug")); HIDE_ACTION(ReportBugAction); - CREATE_ACTION(RequestFeatureAction, tr("Request a feature")); + CREATE_ACTION(RequestFeatureAction, QObject::tr("Request a feature")); HIDE_ACTION(RequestFeatureAction); - CREATE_ACTION(AboutAction, tr("About Kiwix")); + CREATE_ACTION(AboutAction, QObject::tr("About Kiwix")); - CREATE_ACTION_ICON(SettingAction, "settings", tr("Settings")); + CREATE_ACTION_ICON(SettingAction, "settings", QObject::tr("Settings")); SET_SHORTCUT(SettingAction, QKeySequence::Preferences); HIDE_ACTION(SettingAction); - CREATE_ACTION_ICON(DonateAction, "donate", tr("Donate to support Kiwix")); + CREATE_ACTION_ICON(DonateAction, "donate", QObject::tr("Donate to support Kiwix")); //SET_SHORTCUT(DonateAction, QKeySequence(Qt::CTRL+Qt::Key_BracketLeft+Qt::Key_3)); HIDE_ACTION(DonateAction); - CREATE_ACTION_ICON(ExitAction, "exit", tr("Exit")); + CREATE_ACTION_ICON(ExitAction, "exit", QObject::tr("Exit")); SET_SHORTCUT(ExitAction, QKeySequence::Quit); } diff --git a/src/library.cpp b/src/library.cpp index 2647839..46157bd 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -1,6 +1,5 @@ #include "library.h" -#include #include Library::Library() @@ -17,7 +16,7 @@ QString Library::openBook(const QString &zimPath) if(QString::fromStdString(it->second->getZimFilePath()) == zimPath) return it->first; } - qInfo() << QObject::tr("Opening") << zimPath; + qInfo() << "Opening" << zimPath; auto zimPath_ = zimPath.toStdString(); auto reader = std::shared_ptr(new kiwix::Reader(zimPath_)); auto id = QString::fromStdString(reader->getId() + ".zim"); diff --git a/src/main.cpp b/src/main.cpp index 107a9b7..defba0b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,5 @@ #include "kiwixapp.h" -#include -#include #include #include @@ -10,20 +8,6 @@ int main(int argc, char *argv[]) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); KiwixApp a(argc, argv); - // format systems language - QString defaultLocale = QLocale::system().name(); // e.g. "de_DE" - defaultLocale.truncate(defaultLocale.lastIndexOf('_')); // e.g. "de" - QLocale::setDefault(defaultLocale); - - QTranslator qtTranslator; - qtTranslator.load("qt_" + QLocale::system().name(), - QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - a.installTranslator(&qtTranslator); - - QTranslator myappTranslator; - myappTranslator.load(":/i18n/kiwix-desktop.qm"); - a.installTranslator(&myappTranslator); - QCommandLineParser parser; parser.addPositionalArgument("zimfile", "The zim file"); diff --git a/src/mainmenu.cpp b/src/mainmenu.cpp index 0e2477c..5ed08be 100644 --- a/src/mainmenu.cpp +++ b/src/mainmenu.cpp @@ -1,4 +1,4 @@ -#include +#include #include "mainmenu.h" #include "kiwixapp.h" @@ -15,7 +15,7 @@ MainMenu::MainMenu(QWidget *parent) : ADD_ACTION(PrintAction); addSeparator(); - m_fileMenu.setTitle(tr("File")); + m_fileMenu.setTitle(QObject::tr("File")); m_fileMenu.ADD_ACTION(NewTabAction); m_fileMenu.ADD_ACTION(CloseTabAction); m_fileMenu.ADD_ACTION(ReopenClosedTabAction); @@ -25,13 +25,13 @@ MainMenu::MainMenu(QWidget *parent) : m_fileMenu.ADD_ACTION(SavePageAsAction); addMenu(&m_fileMenu); - m_editMenu.setTitle(tr("Edit")); + m_editMenu.setTitle(QObject::tr("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(QObject::tr("View")); m_viewMenu.ADD_ACTION(ToggleFullscreenAction); m_viewMenu.ADD_ACTION(ToggleTOCAction); m_viewMenu.ADD_ACTION(ToggleReadingListAction); @@ -40,11 +40,11 @@ MainMenu::MainMenu(QWidget *parent) : m_viewMenu.ADD_ACTION(ZoomResetAction); addMenu(&m_viewMenu); - m_toolsMenu.setTitle(tr("Tools")); + m_toolsMenu.setTitle(QObject::tr("Tools")); // m_toolsMenu.addAction(); // addMenu(&m_toolsMenu); - m_helpMenu.setTitle(tr("Help")); + m_helpMenu.setTitle(QObject::tr("Help")); m_helpMenu.ADD_ACTION(HelpAction); m_helpMenu.ADD_ACTION(FeedbackAction); m_helpMenu.ADD_ACTION(ReportBugAction); diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 6d045c4..02b3047 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -1,6 +1,6 @@ #include "searchbar.h" -#include +#include #include #include @@ -10,7 +10,7 @@ SearchBar::SearchBar(QWidget *parent) : QLineEdit(parent), m_completer(&m_completionModel, this) { - setPlaceholderText(tr("Search")); + setPlaceholderText(QObject::tr("Search")); m_completer.setCompletionMode(QCompleter::UnfilteredPopupCompletion); setCompleter(&m_completer); connect(this, &QLineEdit::textEdited, this, &SearchBar::updateCompletion); diff --git a/src/topwidget.cpp b/src/topwidget.cpp index 942cd69..4050e0c 100644 --- a/src/topwidget.cpp +++ b/src/topwidget.cpp @@ -4,7 +4,7 @@ #include "kiwixapp.h" #include "mainmenu.h" -#include +#include #include #include @@ -13,16 +13,16 @@ 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(QObject::tr("back")); + mp_historyBackAction->setToolTip(QObject::tr("back")); connect(mp_historyBackAction, &QAction::triggered, [this](){ KiwixApp::instance()->getTabWidget()->triggerWebPageAction(QWebEnginePage::Back); }); addAction(mp_historyBackAction); 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(QObject::tr("forward")); + mp_historyForwardAction->setToolTip(QObject::tr("forward")); connect(mp_historyForwardAction, &QAction::triggered, [this](){ KiwixApp::instance()->getTabWidget()->triggerWebPageAction(QWebEnginePage::Forward); }); From 0c6cdc4ac4e48a808d21c78f7a8e7d2947e057e0 Mon Sep 17 00:00:00 2001 From: Thierry Date: Wed, 22 Aug 2018 16:55:57 +0000 Subject: [PATCH 05/10] Update translations --- resources/i18n/kiwix-desktop_fr.qm | Bin 3381 -> 3320 bytes resources/i18n/kiwix-desktop_fr.ts | 8 -------- 2 files changed, 8 deletions(-) diff --git a/resources/i18n/kiwix-desktop_fr.qm b/resources/i18n/kiwix-desktop_fr.qm index 7494cb15679606451eab2bf15a7a00918edf6952..e53b461a4ca11a663761af0062df021832ce33c4 100644 GIT binary patch delta 119 zcmdlg^+R%kh-Cl+%Wf712F{}lEa!nV<7Wnz3#vf=7Y3F$1`G_$aS)nInSu5EaRvsi zDh9Up*$fQa3KM(#`wiW9%3iG}d~38`aX;IQDYyFUeJPF^NZ Rar@>X#*>_z3%HLm0su>h1s!-Bu= z{uH2KUM5h}p3PZ|Cpis-82lMZ8Oj(^8HyN6fUF{hR1O9pU;|=y|AN%K%)E4V5Zfm+ OsVK3iaQuitter - - Library - - - Opening - Ouverture - - MainMenu From 2304987bcf84eb8304a1982cb67d61415f3de4e7 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 5 Sep 2018 15:35:21 +0200 Subject: [PATCH 06/10] Make the QTranslator members of KiwixApp. If we pass their address to `installTranslator` we have to be sure they exist after we quit the constructor. --- src/kiwixapp.cpp | 13 +++++-------- src/kiwixapp.h | 2 ++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/kiwixapp.cpp b/src/kiwixapp.cpp index 956addc..2b91178 100644 --- a/src/kiwixapp.cpp +++ b/src/kiwixapp.cpp @@ -2,7 +2,6 @@ #include "zim/error.h" #include -#include #include #include #include @@ -16,14 +15,12 @@ KiwixApp::KiwixApp(int& argc, char *argv[]) : QApplication(argc, argv) { - QTranslator qtTranslator; - qtTranslator.load("qt_" + QLocale::system().name(), - QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - installTranslator(&qtTranslator); + m_qtTranslator.load("qt_" + QLocale::system().name(), + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + installTranslator(&m_qtTranslator); - QTranslator myappTranslator; - myappTranslator.load(":/i18n/kiwix-desktop.qm"); - installTranslator(&myappTranslator); + m_appTranslator.load(":/i18n/kiwix-desktop.qm"); + installTranslator(&m_appTranslator); auto icon = QIcon(); icon.addFile(":/icons/kiwix/app_icon.svg"); diff --git a/src/kiwixapp.h b/src/kiwixapp.h index 8b12b70..b53c9cf 100644 --- a/src/kiwixapp.h +++ b/src/kiwixapp.h @@ -10,6 +10,7 @@ #include #include +#include class KiwixApp : public QApplication @@ -72,6 +73,7 @@ protected: void postInit(); private: + QTranslator m_qtTranslator, m_appTranslator; Library m_library; MainWindow* mp_mainWindow; TabWidget* mp_tabWidget; From 171a307a7bc323ea78cf51a8ae128530da41f9be Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 5 Sep 2018 15:37:53 +0200 Subject: [PATCH 07/10] Uniform the way we are loading translation files. It is better to have the same mechanism to load the file instead of one time using `load` method to find the right file and one time using the resources system overloading the resource file. --- resources/translations.qrc | 4 ++-- src/kiwixapp.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/translations.qrc b/resources/translations.qrc index 5100ea5..94ea8f5 100644 --- a/resources/translations.qrc +++ b/resources/translations.qrc @@ -1,5 +1,5 @@ - - i18n/kiwix-desktop_fr.qm + + i18n/kiwix-desktop_fr.qm diff --git a/src/kiwixapp.cpp b/src/kiwixapp.cpp index 2b91178..fbb7416 100644 --- a/src/kiwixapp.cpp +++ b/src/kiwixapp.cpp @@ -15,11 +15,11 @@ KiwixApp::KiwixApp(int& argc, char *argv[]) : QApplication(argc, argv) { - m_qtTranslator.load("qt_" + QLocale::system().name(), + m_qtTranslator.load(QLocale(), "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath)); installTranslator(&m_qtTranslator); - m_appTranslator.load(":/i18n/kiwix-desktop.qm"); + m_appTranslator.load(QLocale(), "kiwix-desktop", "_", ":/i18n/"); installTranslator(&m_appTranslator); auto icon = QIcon(); From d37cdd6e2dbc5c9e7c659db3dcf423cd44eb64c3 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 5 Sep 2018 15:50:54 +0200 Subject: [PATCH 08/10] Do not use `QObject::tr` but directly `tr`. It simplify the code and allow the translation to keep the context (the class of the object) instead of always having the `QObject` context. --- src/kiwixapp.cpp | 59 +++++++++++++++++++++++------------------------ src/mainmenu.cpp | 10 ++++---- src/mainmenu.h | 1 + src/searchbar.cpp | 3 +-- src/topwidget.cpp | 9 ++++---- 5 files changed, 40 insertions(+), 42 deletions(-) diff --git a/src/kiwixapp.cpp b/src/kiwixapp.cpp index fbb7416..3938ba8 100644 --- a/src/kiwixapp.cpp +++ b/src/kiwixapp.cpp @@ -2,7 +2,6 @@ #include "zim/error.h" #include -#include #include #include #include @@ -93,7 +92,7 @@ void KiwixApp::openZimFile(const QString &zimfile) if (_zimfile.isEmpty()) { _zimfile = QFileDialog::getOpenFileName( getMainWindow(), - QObject::tr("Open Zim"), + tr("Open Zim"), QString(), "ZimFile (*.zim*)"); } @@ -171,109 +170,109 @@ QAction *KiwixApp::getAction(KiwixApp::Actions action) void KiwixApp::createAction() { - CREATE_ACTION_ICON(KiwixServeAction, "share", QObject::tr("Local Kiwix Server")); + CREATE_ACTION_ICON(KiwixServeAction, "share", tr("Local Kiwix Server")); SET_SHORTCUT(KiwixServeAction, QKeySequence(Qt::CTRL+Qt::Key_I)); HIDE_ACTION(KiwixServeAction); - CREATE_ACTION_ICON(RandomArticleAction, "random", QObject::tr("Random Article")); + CREATE_ACTION_ICON(RandomArticleAction, "random", tr("Random Article")); SET_SHORTCUT(RandomArticleAction, QKeySequence(Qt::CTRL+Qt::Key_R)); connect(mpa_actions[RandomArticleAction], &QAction::triggered, this, [=]() { this->openRandomUrl(); }); - CREATE_ACTION_ICON(PrintAction, "print", QObject::tr("Print")); + CREATE_ACTION_ICON(PrintAction, "print", tr("Print")); SET_SHORTCUT(PrintAction, QKeySequence::Print); connect(mpa_actions[PrintAction], &QAction::triggered, this, &KiwixApp::printPage); - CREATE_ACTION(NewTabAction, QObject::tr("New tab")); + CREATE_ACTION(NewTabAction, tr("New tab")); SET_SHORTCUT(NewTabAction, QKeySequence::AddTab); - CREATE_ACTION(CloseTabAction, QObject::tr("Close tab")); + CREATE_ACTION(CloseTabAction, tr("Close tab")); SET_SHORTCUT(CloseTabAction, QKeySequence::Close); - CREATE_ACTION(ReopenClosedTabAction, QObject::tr("Reopen closed tab")); + CREATE_ACTION(ReopenClosedTabAction, tr("Reopen closed tab")); SET_SHORTCUT(ReopenClosedTabAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_T)); HIDE_ACTION(ReopenClosedTabAction); - CREATE_ACTION(BrowseLibraryAction, QObject::tr("Browse library")); + CREATE_ACTION(BrowseLibraryAction, tr("Browse library")); SET_SHORTCUT(BrowseLibraryAction, QKeySequence(Qt::CTRL+Qt::Key_E)); HIDE_ACTION(BrowseLibraryAction); - CREATE_ACTION(OpenFileAction, QObject::tr("Open file")); + CREATE_ACTION(OpenFileAction, tr("Open file")); SET_SHORTCUT(OpenFileAction, QKeySequence::Open); connect(mpa_actions[OpenFileAction], &QAction::triggered, this, [=]() { openZimFile(); }); - CREATE_ACTION(OpenRecentAction, QObject::tr("Open recent")); + CREATE_ACTION(OpenRecentAction, tr("Open recent")); HIDE_ACTION(OpenRecentAction); - CREATE_ACTION(SavePageAsAction, QObject::tr("Save page as ...")); + CREATE_ACTION(SavePageAsAction, tr("Save page as ...")); SET_SHORTCUT(SavePageAsAction, QKeySequence::SaveAs); HIDE_ACTION(SavePageAsAction); - CREATE_ACTION(SearchArticleAction, QObject::tr("Search article")); + CREATE_ACTION(SearchArticleAction, tr("Search article")); SET_SHORTCUT(SearchArticleAction, QKeySequence(Qt::CTRL+Qt::Key_L)); HIDE_ACTION(SearchArticleAction); - CREATE_ACTION(SearchLibraryAction, QObject::tr("Search in library")); + CREATE_ACTION(SearchLibraryAction, tr("Search in library")); SET_SHORTCUT(SearchLibraryAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_R)); HIDE_ACTION(SearchLibraryAction); - CREATE_ACTION(FindInPageAction, QObject::tr("Find in page")); + CREATE_ACTION(FindInPageAction, tr("Find in page")); SET_SHORTCUT(FindInPageAction, QKeySequence::Find); - CREATE_ACTION_ICON(ToggleFullscreenAction, "full-screen-enter", QObject::tr("Set fullScreen")); + CREATE_ACTION_ICON(ToggleFullscreenAction, "full-screen-enter", tr("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 ? QObject::tr("Quit fullScreen") : QObject::tr("Set fullScreen")); + action->setText(checked ? tr("Quit fullScreen") : tr("Set fullScreen")); }); mpa_actions[ToggleFullscreenAction]->setCheckable(true); - CREATE_ACTION(ToggleTOCAction, QObject::tr("Table of content")); + CREATE_ACTION(ToggleTOCAction, tr("Table of content")); SET_SHORTCUT(ToggleTOCAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_1)); HIDE_ACTION(ToggleTOCAction); - CREATE_ACTION(ToggleReadingListAction, QObject::tr("Reading list")); + CREATE_ACTION(ToggleReadingListAction, tr("Reading list")); SET_SHORTCUT(ToggleReadingListAction, QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_2)); HIDE_ACTION(ToggleReadingListAction); - CREATE_ACTION(ZoomInAction, QObject::tr("Zoom in")); + CREATE_ACTION(ZoomInAction, tr("Zoom in")); SET_SHORTCUT(ZoomInAction, QKeySequence::ZoomIn); - CREATE_ACTION(ZoomOutAction, QObject::tr("Zoom out")); + CREATE_ACTION(ZoomOutAction, tr("Zoom out")); SET_SHORTCUT(ZoomOutAction, QKeySequence::ZoomOut); - CREATE_ACTION(ZoomResetAction, QObject::tr("Zoom reset")); + CREATE_ACTION(ZoomResetAction, tr("Zoom reset")); SET_SHORTCUT(ZoomResetAction, QKeySequence(Qt::CTRL+Qt::Key_0)); - CREATE_ACTION(HelpAction, QObject::tr("Help")); + CREATE_ACTION(HelpAction, tr("Help")); SET_SHORTCUT(HelpAction, QKeySequence::HelpContents); HIDE_ACTION(HelpAction); - CREATE_ACTION(FeedbackAction, QObject::tr("Feedback")); + CREATE_ACTION(FeedbackAction, tr("Feedback")); HIDE_ACTION(FeedbackAction); - CREATE_ACTION(ReportBugAction, QObject::tr("Repost a bug")); + CREATE_ACTION(ReportBugAction, tr("Repost a bug")); HIDE_ACTION(ReportBugAction); - CREATE_ACTION(RequestFeatureAction, QObject::tr("Request a feature")); + CREATE_ACTION(RequestFeatureAction, tr("Request a feature")); HIDE_ACTION(RequestFeatureAction); - CREATE_ACTION(AboutAction, QObject::tr("About Kiwix")); + CREATE_ACTION(AboutAction, tr("About Kiwix")); - CREATE_ACTION_ICON(SettingAction, "settings", QObject::tr("Settings")); + CREATE_ACTION_ICON(SettingAction, "settings", tr("Settings")); SET_SHORTCUT(SettingAction, QKeySequence::Preferences); HIDE_ACTION(SettingAction); - CREATE_ACTION_ICON(DonateAction, "donate", QObject::tr("Donate to support Kiwix")); + CREATE_ACTION_ICON(DonateAction, "donate", tr("Donate to support Kiwix")); //SET_SHORTCUT(DonateAction, QKeySequence(Qt::CTRL+Qt::Key_BracketLeft+Qt::Key_3)); HIDE_ACTION(DonateAction); - CREATE_ACTION_ICON(ExitAction, "exit", QObject::tr("Exit")); + CREATE_ACTION_ICON(ExitAction, "exit", tr("Exit")); SET_SHORTCUT(ExitAction, QKeySequence::Quit); } diff --git a/src/mainmenu.cpp b/src/mainmenu.cpp index 5ed08be..d3b475a 100644 --- a/src/mainmenu.cpp +++ b/src/mainmenu.cpp @@ -15,7 +15,7 @@ MainMenu::MainMenu(QWidget *parent) : ADD_ACTION(PrintAction); addSeparator(); - m_fileMenu.setTitle(QObject::tr("File")); + m_fileMenu.setTitle(tr("File")); m_fileMenu.ADD_ACTION(NewTabAction); m_fileMenu.ADD_ACTION(CloseTabAction); m_fileMenu.ADD_ACTION(ReopenClosedTabAction); @@ -25,13 +25,13 @@ MainMenu::MainMenu(QWidget *parent) : m_fileMenu.ADD_ACTION(SavePageAsAction); addMenu(&m_fileMenu); - m_editMenu.setTitle(QObject::tr("Edit")); + m_editMenu.setTitle(tr("Edit")); m_editMenu.ADD_ACTION(SearchArticleAction); m_editMenu.ADD_ACTION(SearchLibraryAction); m_editMenu.ADD_ACTION(FindInPageAction); addMenu(&m_editMenu); - m_viewMenu.setTitle(QObject::tr("View")); + m_viewMenu.setTitle(tr("View")); m_viewMenu.ADD_ACTION(ToggleFullscreenAction); m_viewMenu.ADD_ACTION(ToggleTOCAction); m_viewMenu.ADD_ACTION(ToggleReadingListAction); @@ -40,11 +40,11 @@ MainMenu::MainMenu(QWidget *parent) : m_viewMenu.ADD_ACTION(ZoomResetAction); addMenu(&m_viewMenu); - m_toolsMenu.setTitle(QObject::tr("Tools")); + m_toolsMenu.setTitle(tr("Tools")); // m_toolsMenu.addAction(); // addMenu(&m_toolsMenu); - m_helpMenu.setTitle(QObject::tr("Help")); + m_helpMenu.setTitle(tr("Help")); m_helpMenu.ADD_ACTION(HelpAction); m_helpMenu.ADD_ACTION(FeedbackAction); m_helpMenu.ADD_ACTION(ReportBugAction); diff --git a/src/mainmenu.h b/src/mainmenu.h index 124c122..e816052 100644 --- a/src/mainmenu.h +++ b/src/mainmenu.h @@ -5,6 +5,7 @@ class MainMenu : public QMenu { + Q_OBJECT public: MainMenu(QWidget *parent=nullptr); diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 02b3047..a3e187c 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -1,6 +1,5 @@ #include "searchbar.h" -#include #include #include @@ -10,7 +9,7 @@ SearchBar::SearchBar(QWidget *parent) : QLineEdit(parent), m_completer(&m_completionModel, this) { - setPlaceholderText(QObject::tr("Search")); + setPlaceholderText(tr("Search")); m_completer.setCompletionMode(QCompleter::UnfilteredPopupCompletion); setCompleter(&m_completer); connect(this, &QLineEdit::textEdited, this, &SearchBar::updateCompletion); diff --git a/src/topwidget.cpp b/src/topwidget.cpp index 4050e0c..6b74845 100644 --- a/src/topwidget.cpp +++ b/src/topwidget.cpp @@ -4,7 +4,6 @@ #include "kiwixapp.h" #include "mainmenu.h" -#include #include #include @@ -13,16 +12,16 @@ TopWidget::TopWidget(QWidget *parent) : { mp_historyBackAction = new QAction(this); mp_historyBackAction->setIcon(QIcon(":/icons/back.svg")); - mp_historyBackAction->setText(QObject::tr("back")); - mp_historyBackAction->setToolTip(QObject::tr("back")); + mp_historyBackAction->setText(tr("back")); + mp_historyBackAction->setToolTip(tr("back")); connect(mp_historyBackAction, &QAction::triggered, [this](){ KiwixApp::instance()->getTabWidget()->triggerWebPageAction(QWebEnginePage::Back); }); addAction(mp_historyBackAction); mp_historyForwardAction = new QAction(this); mp_historyForwardAction->setIcon(QIcon(":/icons/forward.svg")); - mp_historyForwardAction->setText(QObject::tr("forward")); - mp_historyForwardAction->setToolTip(QObject::tr("forward")); + mp_historyForwardAction->setText(tr("forward")); + mp_historyForwardAction->setToolTip(tr("forward")); connect(mp_historyForwardAction, &QAction::triggered, [this](){ KiwixApp::instance()->getTabWidget()->triggerWebPageAction(QWebEnginePage::Forward); }); From 457d9aafef5499d5074e9aafab5eede8b340c025 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 5 Sep 2018 15:40:38 +0200 Subject: [PATCH 09/10] Update translations. --- resources/i18n/kiwix-desktop_fr.qm | Bin 3320 -> 3284 bytes resources/i18n/kiwix-desktop_fr.ts | 252 +++++++++++++++++++++++------ 2 files changed, 205 insertions(+), 47 deletions(-) diff --git a/resources/i18n/kiwix-desktop_fr.qm b/resources/i18n/kiwix-desktop_fr.qm index e53b461a4ca11a663761af0062df021832ce33c4..be556246d5566dc2c77afeed97b50973e4fda047 100644 GIT binary patch delta 414 zcmew%c|~%9OuZ%p%Xt?I5g zta^;8-{vtea1=6ryS5LgZxZ7lem@3=dX{b`_6QxIc2j1d^s7LL$IQ2j(}5PGF~64= z2Wq^?a3 z0@c^Coj#ud#mFA(MfD-GqC(%uI#=28MgwyPBhc3Y2)* zX1M|tZ09iy1-h6+foC^kF;L-ip6iNRf%5qfnoE#3^Trbf25tl1KOuEM`8oV`_oo2W zUjmxSoxC}V@fg$QGc5k>j9QcJIh7|fvM6$M`6g!Og=glabFk=H^ Y7PtJOTy`LXDK~@|7Vv%^0Z8hvDLqrwk0NwTyDvOMvt##?)`~ zfadZte!I4hfq`9*@ejWrP+XmfJwk_pp`O8%St$J~P@I>d6aN(tzoJFK%iW&q`1v7T7?8OY~heIZ{2R42?PKIa6`8B^He3$6eyvSpiY z-~{xLHQRyIxj=_Wv7J7j0p!=SuRPrZ)Yr~__Xo(qGr8F=WHJOWuwUSwE;AEoz&-9= z&Cx&$m3Y`@xdIgg^B9H#eZaAYXE$RpkZ$I=uDBH_pU<0l;|VY%LU{j#)B(jU`0MUZ z0a~1w2^4JKoW*#INm7L&grSHbpP`hYj3E`sQeemd(h3a4lNa)cnsT~j=A|g)rB;-% z1MTJT&MeQYa4aZbWCrpyaOf AboutDialog - + About A propos - + qrc:/texts/about.html qrc:/texts/about.html @@ -17,158 +17,156 @@ KiwixApp - + Open Zim Ouvrir Zim - + Local Kiwix Server Serveur local Kiwix - + Random Article Article aléatoire - + Print Imprimer - + New tab Nouvel onglet - + Close tab Fermer l'onglet - + Reopen closed tab Rouvrir l'onglet fermé - + Browse library Parcourir la bibliothèque - + Open file Ouvrir un ficher - + Open recent Fichiers récemment ouverts - + Save page as ... Enregister sous... - + Search article Chercher un article - + Search in library Chercher dans la bibliothèque - + Find in page Chercher dans la page - Find next - Trouver le suivant + Trouver le suivant - Find previous - Trouver le précédent + Trouver le précédent - - + + Set fullScreen Mode plein écran - + Quit fullScreen Quitter le pein écran - + Table of content Table des matières - + Reading list Liste de lecture - + Zoom in Zoom + - + Zoom out Zoom - - + Zoom reset Réinitialisation du zoom - + Help Aide - + Feedback Retour d'information - + Repost a bug Déclarer un bogue - + Request a feature Demander une nouvelle fonctionnalité - + About Kiwix A propos de Kiwix - + Settings Paramètres - + Donate to support Kiwix Faire un don pour soutenir Kiwix - + Exit Quitter @@ -176,27 +174,27 @@ MainMenu - + File Fichier - + Edit Édition - + View Affichage - + Tools Outils - + Help Aide @@ -204,30 +202,190 @@ MainWindow - + MainWindow MainWindow + + + Find in page + Chercher dans la page + + + + QObject + + Open Zim + Ouvrir Zim + + + Local Kiwix Server + Serveur local Kiwix + + + Random Article + Article aléatoire + + + Print + Imprimer + + + New tab + Nouvel onglet + + + Close tab + Fermer l'onglet + + + Reopen closed tab + Rouvrir l'onglet fermé + + + Browse library + Parcourir la bibliothèque + + + Open file + Ouvrir un ficher + + + Open recent + Fichiers récemment ouverts + + + Save page as ... + Enregister sous... + + + Search article + Chercher un article + + + Search in library + Chercher dans la bibliothèque + + + Find in page + Chercher dans la page + + + Set fullScreen + Mode plein écran + + + Quit fullScreen + Quitter le pein écran + + + Table of content + Table des matières + + + Reading list + Liste de lecture + + + Zoom in + Zoom + + + + Zoom out + Zoom - + + + Zoom reset + Réinitialisation du zoom + + + Help + Aide + + + Feedback + Retour d'information + + + Repost a bug + Déclarer un bogue + + + Request a feature + Demander une nouvelle fonctionnalité + + + About Kiwix + A propos de Kiwix + + + Settings + Paramètres + + + Donate to support Kiwix + Faire un don pour soutenir Kiwix + + + Exit + Quitter + + + File + Fichier + + + Edit + Édition + + + View + Affichage + + + Tools + Outils + + + Search + Recherche + + + back + Précédent + + + forward + Suivant + SearchBar - + Search Recherche + + TocSideBar + + + Form + + + TopWidget - - + + back Précédent - - + + forward Suivant From bf8fab75d8b4d280ac4a20c132fe4d77f4c5bcd9 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 5 Sep 2018 15:41:02 +0200 Subject: [PATCH 10/10] Add a translation for `texts/about.html`. --- resources/kiwix.qrc | 3 +++ resources/texts/fr/about.html | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 resources/texts/fr/about.html diff --git a/resources/kiwix.qrc b/resources/kiwix.qrc index fab3b66..68b5a44 100644 --- a/resources/kiwix.qrc +++ b/resources/kiwix.qrc @@ -65,4 +65,7 @@ icons/search_backward.svg icons/search_forward.svg + + texts/fr/about.html + diff --git a/resources/texts/fr/about.html b/resources/texts/fr/about.html new file mode 100644 index 0000000..d8619e9 --- /dev/null +++ b/resources/texts/fr/about.html @@ -0,0 +1,29 @@ + + + + +

Kiwix Desktop

+

Kiwix vous permet d'avoir tout Wikipedia à portée de main où que vous alliez! Dans un bateau, au milieu de nul-part ou en prison, Kiwix vous donne accès à l'ensemble du savoir humain. Vous n'avez pas besoin d'internet, tout est conservé dans votre ordinateur.

+

En apprendre plus sur Kiwix

+

Release

+

+Ce logiciel est publié selon les conditions de la licence GNU General Public License version 3. Lisez le code source sur Github. +

+

Version : %%VERSION%%

+

Date de compilation : %%BUILD_DATE%%

+

Reporter un problème

+

Pour ouvrir un rapport de bogue, visitez Kiwix-desktop issue et ouvrez une "issue" décrivant votre problème.

+

S'il vous plaît, mentionnez la version et la date de compilation dans le rapport.

+

Bibliothèques

+ +