Commit 40546f9a authored by Oswald Buddenhagen's avatar Oswald Buddenhagen

load translations

parent 067bab07
......@@ -38,6 +38,9 @@
#include <QtCore/QFileInfo>
#include <QtCore/QDebug>
#include <QtCore/QTimer>
#include <QtCore/QLibraryInfo>
#include <QtCore/QTranslator>
#include <QtCore/QVariant>
#include <QtGui/QMessageBox>
#include <QtGui/QApplication>
......@@ -197,6 +200,12 @@ static inline QStringList getPluginPaths()
return rc;
}
#ifdef Q_OS_MAC
# define SHARE_PATH "/../Resources"
#else
# define SHARE_PATH "/../share/qtcreator"
#endif
int main(int argc, char **argv)
{
#ifdef Q_OS_DARWIN
......@@ -208,6 +217,23 @@ int main(int argc, char **argv)
#endif
SharedTools::QtSingleApplication app((QLatin1String(appNameC)), argc, argv);
QTranslator translator;
QTranslator qtTranslator;
const QString &locale = QLocale::system().name();
if (translator.load(QLatin1String("qtcreator_") + locale,
QCoreApplication::applicationDirPath()
+ QLatin1String(SHARE_PATH "/translations"))) {
if (qtTranslator.load(QLatin1String("qt_") + locale,
QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
app.installTranslator(&translator);
app.installTranslator(&qtTranslator);
app.setProperty("qtc_locale", locale);
} else {
translator.load(QString()); // unload()
}
}
// Load
ExtensionSystem::PluginManager pluginManager;
pluginManager.setFileExtension(QLatin1String("pluginspec"));
......
......@@ -44,9 +44,12 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/uniqueidmanager.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QtPlugin>
#include <QtCore/QDebug>
#include <QtCore/QProcess>
#include <QtCore/QLibraryInfo>
#include <QtCore/QTranslator>
#ifdef CPP_ENABLED
# include <QtGui/QAction>
......@@ -115,6 +118,14 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
FormEditorW::ensureInitStage(FormEditorW::RegisterPlugins);
}
QString locale = qApp->property("qtc_locale").toString();
if (!locale.isEmpty()) {
QTranslator *qtr = new QTranslator(this);
qtr->load(QLatin1String("designer_") + locale,
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
qApp->installTranslator(qtr);
}
error->clear();
return true;
}
......
......@@ -58,6 +58,8 @@
#include <QtCore/QSettings>
#include <QtCore/QDir>
#include <QtCore/QResource>
#include <QtCore/QLibraryInfo>
#include <QtCore/QTranslator>
#include <QtGui/QAction>
#include <QtGui/QShortcut>
#include <QtGui/QSplitter>
......@@ -129,6 +131,14 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
QList<int> modecontext;
modecontext << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_MODE_HELP);
QString locale = qApp->property("qtc_locale").toString();
if (!locale.isEmpty()) {
QTranslator *qtr = new QTranslator(this);
qtr->load(QLatin1String("assistant_") + locale,
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
qApp->installTranslator(qtr);
}
// FIXME shouldn't the help engine create the directory if it doesn't exist?
QFileInfo fi(m_core->settings()->fileName());
QDir directory(fi.absolutePath()+"/qtcreator");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment