Skip to content

Commit

Permalink
Merge pull request #66 from volkov0aa/fix-translations
Browse files Browse the repository at this point in the history
Make more strings translatable and load Qt's translations
  • Loading branch information
Mezomish committed Jul 22, 2014
2 parents 5fc4f19 + 62bfe72 commit 5902d3e
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 27 deletions.
8 changes: 6 additions & 2 deletions plugins/colorpicker/ColorPickerPlugin.cpp
Expand Up @@ -10,10 +10,10 @@
#include "ColorFormatDlg.h"

ColorPickerPlugin::ColorPickerPlugin() : QObject(), JuffPlugin() {
_pickColorAct = new QAction(QIcon(":icon32"), "Pick a color", this);
_pickColorAct = new QAction(QIcon(":icon32"), tr("Pick a color"), this);
connect(_pickColorAct, SIGNAL(triggered()), SLOT(pickColor()));
// toolbar
_toolBar = new QToolBar("ColorPickerPlugin");
_toolBar = new QToolBar(tr("Color Picker"));
_toolBar->setObjectName("ColorPickerToolbar");
_toolBar->addAction(_pickColorAct);
}
Expand All @@ -25,6 +25,10 @@ QString ColorPickerPlugin::name() const {
return "Color Picker";
}

QString ColorPickerPlugin::title() const {
return tr("Color Picker");
}

QString ColorPickerPlugin::targetEngine() const {
return "all";
}
Expand Down
1 change: 1 addition & 0 deletions plugins/colorpicker/ColorPickerPlugin.h
Expand Up @@ -16,6 +16,7 @@ Q_INTERFACES(JuffPlugin)
virtual ~ColorPickerPlugin();

virtual QString name() const;
virtual QString title() const;
virtual QString description() const;
virtual QString targetEngine() const;

Expand Down
4 changes: 4 additions & 0 deletions plugins/doclist/DocListPlugin.cpp
Expand Up @@ -29,6 +29,10 @@ QString DocListPlugin::name() const {
return "Documents List";
}

QString DocListPlugin::title() const {
return tr("Documents List");
}

QString DocListPlugin::targetEngine() const {
return "all";
}
Expand Down
1 change: 1 addition & 0 deletions plugins/doclist/DocListPlugin.h
Expand Up @@ -21,6 +21,7 @@ Q_INTERFACES(JuffPlugin)

// info
virtual QString name() const;
virtual QString title() const;
virtual QString description() const;
virtual QString targetEngine() const;

Expand Down
6 changes: 5 additions & 1 deletion plugins/favorites/FavoritesPlugin.cpp
Expand Up @@ -8,7 +8,7 @@
#include <PluginSettings.h>

FavoritesPlugin::FavoritesPlugin() : QObject(), JuffPlugin() {
menu_ = new QMenu("Favorites");
menu_ = new QMenu(tr("F&avorites"));
addAct_ = new QAction(tr("Add current file"), 0);
manageAct_ = new QAction(tr("Manage favorites"), 0);
connect(addAct_, SIGNAL(triggered()), SLOT(addCurrent()));
Expand All @@ -24,6 +24,10 @@ QString FavoritesPlugin::name() const {
return "Favorites";
}

QString FavoritesPlugin::title() const {
return tr("Favorites");
}

QString FavoritesPlugin::targetEngine() const {
return "all";
}
Expand Down
1 change: 1 addition & 0 deletions plugins/favorites/FavoritesPlugin.h
Expand Up @@ -17,6 +17,7 @@ Q_INTERFACES(JuffPlugin)

// info
virtual QString name() const;
virtual QString title() const;
virtual QString description() const;
virtual QString targetEngine() const;

Expand Down
10 changes: 7 additions & 3 deletions plugins/findinfiles/FindInFilesPlugin.cpp
Expand Up @@ -32,7 +32,7 @@ class FindInFilesPlugin::PluginInterior {
searchAct_->setIcon(parent->api()->iconManager()->icon("main:find"));

// create toolbar
toolBar_ = new QToolBar("Find In Files");
toolBar_ = new QToolBar(tr("Find In Files"));
toolBar_->setObjectName("FindInFilesToolBar");
toolBar_->addWidget(new QLabel(tr("Find: ")));
toolBar_->addWidget(ed_);
Expand All @@ -42,7 +42,7 @@ class FindInFilesPlugin::PluginInterior {
// create widget that will be embedded into dock
// and put controls to it
widget_ = new QWidget();
widget_->setWindowTitle("Search results");
widget_->setWindowTitle(tr("Search results"));
tree_ = new QTreeWidget();
QVBoxLayout* vBox = new QVBoxLayout();

Expand All @@ -51,7 +51,7 @@ class FindInFilesPlugin::PluginInterior {
widget_->setLayout(vBox);

QStringList labels;
labels << "File" << "Line" << "Text" << "Column";
labels << tr("File") << tr("Line") << tr("Text") << tr("Column");
tree_->setHeaderLabels(labels);
tree_->setRootIsDecorated(false);
#if QT_VERSION < 0x050000
Expand Down Expand Up @@ -106,6 +106,10 @@ QString FindInFilesPlugin::name() const {
return "Find In Files";
}

QString FindInFilesPlugin::title() const {
return tr("Find In Files");
}

QString FindInFilesPlugin::targetEngine() const {
return "all";
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/findinfiles/FindInFilesPlugin.h
Expand Up @@ -19,6 +19,8 @@ Q_INTERFACES(JuffPlugin)

// plugin name
virtual QString name() const;
// plugin title
virtual QString title() const;
// plugin description
virtual QString description() const;
// engines
Expand Down
4 changes: 4 additions & 0 deletions plugins/fm/FMPlugin.cpp
Expand Up @@ -102,6 +102,10 @@ QString FMPlugin::name() const {
return "File manager";
}

QString FMPlugin::title() const {
return tr("File manager");
}

QString FMPlugin::targetEngine() const {
return "all";
}
Expand Down
1 change: 1 addition & 0 deletions plugins/fm/FMPlugin.h
Expand Up @@ -24,6 +24,7 @@ Q_INTERFACES(JuffPlugin)

// info
virtual QString name() const;
virtual QString title() const;
virtual QString description() const;
virtual QString targetEngine() const;

Expand Down
4 changes: 4 additions & 0 deletions plugins/keybindings/KeysPlugin.cpp
Expand Up @@ -25,6 +25,10 @@ QString KeysPlugin::name() const {
return "Keybindings";
}

QString KeysPlugin::title() const {
return tr("Key bindings");
}

QString KeysPlugin::targetEngine() const {
return "all";
}
Expand Down
1 change: 1 addition & 0 deletions plugins/keybindings/KeysPlugin.h
Expand Up @@ -19,6 +19,7 @@ Q_INTERFACES(JuffPlugin)

// info
virtual QString name() const;
virtual QString title() const;
virtual QString description() const;
virtual QString targetEngine() const;

Expand Down
6 changes: 5 additions & 1 deletion plugins/xmlformat/xmlformat.cpp
Expand Up @@ -43,6 +43,10 @@ QString XmlformatPlugin::name() const {
return "XML Formatter";
}

QString XmlformatPlugin::title() const {
return tr("XML Formatter");
}

QString XmlformatPlugin::targetEngine() const {
return "all";
}
Expand All @@ -53,7 +57,7 @@ QString XmlformatPlugin::description() const {

QToolBar* XmlformatPlugin::toolBar() const
{
QToolBar * bar = new QToolBar("XML Formatter");
QToolBar * bar = new QToolBar(tr("XML Formatter"));
bar->addAction(actDoc);
bar->setObjectName("XMLFormatterToolBar");
return bar;
Expand Down
1 change: 1 addition & 0 deletions plugins/xmlformat/xmlformat.h
Expand Up @@ -45,6 +45,7 @@ class XmlformatPlugin : public QObject, public JuffPlugin {
void init();

QString name() const;
QString title() const;
QString description() const;
QString targetEngine() const;

Expand Down
2 changes: 1 addition & 1 deletion src/app/JuffEd.cpp
Expand Up @@ -168,7 +168,7 @@ void JuffEd::initUI() {

CommandStorageInt* st = Juff::Utils::commandStorage();

QToolBar* mainToolBar = new QToolBar("mainToolBar");
QToolBar* mainToolBar = new QToolBar(tr("Main toolbar"));
mainToolBar->setObjectName("mainToolBar");
mainToolBar->addAction(st->action(FILE_NEW));
mainToolBar->addAction(st->action(FILE_OPEN));
Expand Down
4 changes: 4 additions & 0 deletions src/app/main.cpp
Expand Up @@ -7,6 +7,7 @@
#include <QFile>
#include <QFileInfo>
#include <QTranslator>
#include <QLibraryInfo>
#include <qtsingleapplication.h>

#include <iostream>
Expand Down Expand Up @@ -82,6 +83,9 @@ void loadTranslations(QApplication& app) {
}
}

QTranslator* qtTranslator = new QTranslator;
qtTranslator->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(qtTranslator);
// TODO : load plugins translations
}

Expand Down
19 changes: 6 additions & 13 deletions src/app/ui/settings/SettingsDlg.cpp
Expand Up @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include <QtCore/QDir>
#include <QtCore/QStringList>
#include <QPushButton>
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QVBoxLayout>

Expand Down Expand Up @@ -275,12 +276,10 @@ SettingsDlg::SettingsDlg(QWidget* parent) : QDialog(parent) {
setWindowTitle(tr("Settings"));

// create buttons
okBtn_ = new QPushButton(tr("OK"), this);
applyBtn_ = new QPushButton(tr("Apply"), this);
cancelBtn_ = new QPushButton(tr("Cancel"), this);
connect(okBtn_, SIGNAL(clicked()), SLOT(ok()));
connect(applyBtn_, SIGNAL(clicked()), SLOT(apply()));
connect(cancelBtn_, SIGNAL(clicked()), SLOT(reject()));
buttonBox_ = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply);
connect(buttonBox_, SIGNAL(accepted()), SLOT(ok()));
connect(buttonBox_, SIGNAL(rejected()), SLOT(reject()));
connect(buttonBox_->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SLOT(apply()));
// create multipage
mp_ = new MultiPage();

Expand All @@ -298,15 +297,9 @@ SettingsDlg::SettingsDlg(QWidget* parent) : QDialog(parent) {
colorsPage_->addColor(tr("Selection background color"), "editor", "selectionBgColor", EditorSettings::get(EditorSettings::SelectionBgColor));

// layouts
QHBoxLayout* btnLayout = new QHBoxLayout();
btnLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
btnLayout->addWidget(okBtn_);
btnLayout->addWidget(applyBtn_);
btnLayout->addWidget(cancelBtn_);

QVBoxLayout* mainLayout = new QVBoxLayout();
mainLayout->addWidget(mp_);
mainLayout->addLayout(btnLayout);
mainLayout->addWidget(buttonBox_);
setLayout(mainLayout);
}

Expand Down
6 changes: 2 additions & 4 deletions src/app/ui/settings/SettingsDlg.h
Expand Up @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include <QtCore/QMap>
#include <QDialog>

class QPushButton;
class QDialogButtonBox;
class MultiPage;
class PluginPage;
class ColorSettingsPage;
Expand Down Expand Up @@ -55,9 +55,7 @@ protected slots:
private:
void init();

QPushButton* okBtn_;
QPushButton* applyBtn_;
QPushButton* cancelBtn_;
QDialogButtonBox* buttonBox_;
MultiPage* mp_;

QWidget* pluginsMainPage_;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Document.cpp
Expand Up @@ -60,7 +60,7 @@ Document::Document(const QString& fileName)
//, clone_(NULL)
{
if (fileName.isEmpty()) {
fileName_ = QString("Untitled %1").arg(sCount_++);
fileName_ = QString(tr("Untitled %1")).arg(sCount_++);
}
else {
fileName_ = fileName;
Expand Down Expand Up @@ -131,7 +131,7 @@ bool Document::isNoname(const QString& fileName, bool* ok) {
}
return true;
}
return fileName.startsWith("Untitled");
return fileName.startsWith(tr("Untitled"));
}

bool Document::isNoname() const {
Expand Down

0 comments on commit 5902d3e

Please sign in to comment.