Skip to content
This repository has been archived by the owner on Dec 17, 2017. It is now read-only.

Commit

Permalink
Make it possible to load translations for multiple libraries
Browse files Browse the repository at this point in the history
Closes #508
  • Loading branch information
amoskvin committed Dec 3, 2012
1 parent 4c440df commit ffefa90
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libraries/razorqt/libtranslate.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,22 @@
#include <QtCore/QTranslator>
#include <QtCore/QCoreApplication>
#include <QtCore/QLocale>
#include <QtCore/QSet>

inline void libTranslate(const QString &name)
{
static bool alreadyLoaded = false;
if (alreadyLoaded)
static QSet<QString> loadedLibs;

if (loadedLibs.contains(name))
return;

loadedLibs.insert(name);

QString locale = QLocale::system().name();
QTranslator *translator = new QTranslator(qApp);
translator->load(QString("%1/%2_%3.qm").arg(TRANSLATIONS_DIR, name, locale));

QCoreApplication::installTranslator(translator);
alreadyLoaded = true;
}


Expand Down

0 comments on commit ffefa90

Please sign in to comment.