Translation suport

print
Josef Rokos 9 years ago
parent ebf155603a
commit c0db311a23

@ -4,5 +4,6 @@
<file>icons/login_64.png</file> <file>icons/login_64.png</file>
<file>style.css</file> <file>style.css</file>
<file>icons/settings.svg</file> <file>icons/settings.svg</file>
<file>translations/prodejna_cs_CZ.qm</file>
</qresource> </qresource>
</RCC> </RCC>

@ -56,3 +56,7 @@ INCLUDEPATH += $$PWD/../qdecimal/decnumber
RESOURCES += \ RESOURCES += \
appRc.qrc appRc.qrc
TRANSLATIONS = translations/prodejna_cz.ts
DISTFILES +=

@ -1,12 +1,22 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include <QApplication>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QTranslator>
#include <QStringList> #include <QLibraryInfo>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
a.installTranslator(&qtTranslator);
QTranslator myappTranslator;
myappTranslator.load(":/translations/prodejna_" + QLocale::system().name());
a.installTranslator(&myappTranslator);
MainWindow w; MainWindow w;
w.move(QApplication::desktop()->screen()->rect().center() - w.rect().center()); w.move(QApplication::desktop()->screen()->rect().center() - w.rect().center());
w.show(); w.show();

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="cs_CZ">
<context>
<name>LoginDialog</name>
<message>
<location filename="../logindialog.ui" line="14"/>
<location filename="../logindialog.ui" line="70"/>
<source>Login</source>
<translation>Login</translation>
</message>
<message>
<location filename="../logindialog.ui" line="80"/>
<source>Password</source>
<translation>Heslo</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="../mainwindow.ui" line="14"/>
<source>MainWindow</source>
<translation>Nastaveni</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="64"/>
<source>File</source>
<translation>Soubor</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="86"/>
<source>Exit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.ui" line="91"/>
<source>Open database...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.ui" line="100"/>
<source>Login...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.ui" line="105"/>
<location filename="../mainwindow.ui" line="108"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

@ -17,7 +17,7 @@ class AutoForm : public FormBinder<T>
{ {
public: public:
explicit AutoForm(QWidget *parent = 0) { explicit AutoForm(QWidget *parent = 0) {
setParent(parent); this->setParent(parent);
m_serviceConnected = false; m_serviceConnected = false;
m_saved = false; m_saved = false;
} }

@ -6,6 +6,7 @@
#include <QSqlResult> #include <QSqlResult>
#include <QSqlError> #include <QSqlError>
#include <QDebug> #include <QDebug>
#include <QTranslator>
#include <odb/sqlite/database.hxx> #include <odb/sqlite/database.hxx>
@ -49,6 +50,8 @@ void Context::loadPlugins()
m_plugins.append(new Users); m_plugins.append(new Users);
m_plugins.append(new Roles); m_plugins.append(new Roles);
qApp->installTranslator(corePlugin->translator());
QDir pluginsDir(qApp->applicationDirPath() + "/../plugins"); QDir pluginsDir(qApp->applicationDirPath() + "/../plugins");
foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so" << "*.dll")) { foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so" << "*.dll")) {
@ -59,6 +62,9 @@ void Context::loadPlugins()
IPlugin *plugin = qobject_cast<IPlugin*>(p); IPlugin *plugin = qobject_cast<IPlugin*>(p);
if (plugin != NULL) { if (plugin != NULL) {
plugin->init(pluginLoader.metaData()); plugin->init(pluginLoader.metaData());
QTranslator *translator = plugin->translator();
qApp->installTranslator(translator);
m_plugins.append(plugin); m_plugins.append(plugin);
} }
} }

@ -146,3 +146,5 @@ else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
INCLUDEPATH += $$PWD/../qdecimal/src INCLUDEPATH += $$PWD/../qdecimal/src
INCLUDEPATH += $$PWD/../qdecimal/decnumber INCLUDEPATH += $$PWD/../qdecimal/decnumber
TRANSLATIONS = translations/core_cz.ts

@ -25,3 +25,11 @@ void CorePlugin::initServiceUi()
m_settingsUi = new GlobalSettingsForm(); m_settingsUi = new GlobalSettingsForm();
} }
QTranslator *CorePlugin::translator()
{
QTranslator *trans = new QTranslator();
trans->load(":/translations/core_" + QLocale::system().name());
return trans;
}

@ -12,6 +12,10 @@ public:
// IMetaDataPlugin interface // IMetaDataPlugin interface
protected: protected:
virtual void initServiceUi(); virtual void initServiceUi();
// IPlugin interface
public:
QTranslator *translator() override;
}; };
#endif // COREPLUGIN_H #endif // COREPLUGIN_H

@ -7,6 +7,7 @@
#include <QJsonObject> #include <QJsonObject>
#include <QStringList> #include <QStringList>
#include <QIcon> #include <QIcon>
#include <QTranslator>
#include "service.h" #include "service.h"
#include "igridform.h" #include "igridform.h"
@ -71,9 +72,8 @@ public:
return (Service<T>*)m_service; return (Service<T>*)m_service;
} }
virtual QIcon pluginIcon() { virtual QTranslator* translator() { return NULL; }
return QIcon(); virtual QIcon pluginIcon() { return QIcon(); }
}
protected: protected:
QWidget *m_ui; QWidget *m_ui;

Binary file not shown.

@ -0,0 +1,330 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="cs_CZ">
<context>
<name>ColumnDialog</name>
<message>
<location filename="../columndialog.ui" line="14"/>
<source>Select columns</source>
<translation>Volba sloupcu</translation>
</message>
</context>
<context>
<name>FilterDialog</name>
<message>
<location filename="../filterdialog.ui" line="14"/>
<source>Manage filters</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterdialog.cpp" line="63"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterdialog.cpp" line="63"/>
<source>Filter</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FilterUi</name>
<message>
<location filename="../filterui.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterui.ui" line="71"/>
<source>Apply</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterui.ui" line="74"/>
<source>Go</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterui.ui" line="97"/>
<source>Load filter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterui.ui" line="117"/>
<location filename="../filterui.ui" line="120"/>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterui.ui" line="140"/>
<location filename="../filterui.ui" line="143"/>
<source>Manage</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterui.ui" line="209"/>
<source>Add condition &quot;AND&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterui.ui" line="214"/>
<source>Add condition &quot;OR&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterui.ui" line="219"/>
<source>Remove condition</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterui.cpp" line="88"/>
<source>OR</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../filterui.cpp" line="88"/>
<source>AND</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FormDialog</name>
<message>
<location filename="../formdialog.ui" line="17"/>
<source>Edit record</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../formdialog.cpp" line="32"/>
<source>Validation error</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>GlobalSettingsForm</name>
<message>
<location filename="../settings/globalsettingsform.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="20"/>
<source>Company info</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="26"/>
<source>IC</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="36"/>
<source>VAT number</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="46"/>
<source>VAT payer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="56"/>
<source>Contact</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="62"/>
<source>Firm Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="72"/>
<source>Street</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="82"/>
<source>House Number</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="92"/>
<source>City</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="102"/>
<source>ZIP code</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="115"/>
<location filename="../settings/globalsettingsform.ui" line="121"/>
<source>Logo</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings/globalsettingsform.ui" line="128"/>
<source>Select file</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>GridForm</name>
<message>
<location filename="../gridform.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.ui" line="23"/>
<source>Add record</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.ui" line="29"/>
<source>N</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.ui" line="52"/>
<source>Edit record</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.ui" line="55"/>
<source>E</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.ui" line="75"/>
<location filename="../gridform.h" line="188"/>
<source>Delete record</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.ui" line="78"/>
<source>D</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.ui" line="98"/>
<source>Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.ui" line="101"/>
<source>F</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.ui" line="124"/>
<source>Print</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.ui" line="127"/>
<source>P</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.ui" line="190"/>
<source>Select columns</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.h" line="138"/>
<location filename="../gridform.h" line="141"/>
<source>Database error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gridform.h" line="188"/>
<source>Realy delete this record?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RolesForm</name>
<message>
<location filename="../roles/rolesform.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../roles/rolesform.ui" line="23"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../roles/rolesform.ui" line="33"/>
<source>Active</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../roles/rolesform.ui" line="52"/>
<source>Permissions:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SaveFilterDialog</name>
<message>
<location filename="../savefilterdialog.ui" line="14"/>
<location filename="../savefilterdialog.ui" line="23"/>
<source>Filter name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsForm</name>
<message>
<location filename="../settingsform.ui" line="17"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UserForm</name>
<message>
<location filename="../users/userform.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../users/userform.ui" line="20"/>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../users/userform.ui" line="30"/>
<source>Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../users/userform.ui" line="44"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../users/userform.ui" line="57"/>
<source>Is Admin</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../users/userform.ui" line="67"/>
<source>Active</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../users/userform.ui" line="77"/>
<source>Roles</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../users/userform.ui" line="91"/>
<source>Retype Password</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
Loading…
Cancel
Save