Theme: allow enforced locale

This commit is contained in:
Daniel Molkentin 2012-11-16 11:49:55 +01:00
parent 6457153bda
commit 5173de5798
2 changed files with 13 additions and 3 deletions

View file

@ -96,15 +96,19 @@ Application::Application(int &argc, char **argv) :
installTranslator(qtTranslator);
QTranslator *mirallTranslator = new QTranslator(this);
QString locale = Theme::instance()->enforcedLocale();
if (locale.isEmpty()) locale = QLocale::system().name();
#ifdef Q_OS_LINUX
// FIXME - proper path!
mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), QLatin1String("/usr/share/mirall/i18n/"));
mirallTranslator->load(QLatin1String("mirall_") + locale, QLatin1String("/usr/share/mirall/i18n/"));
#endif
#ifdef Q_OS_MAC
mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), applicationDirPath()+QLatin1String("/../translations") ); // path defaults to app dir.
mirallTranslator->load(QLatin1String("mirall_") + locale, applicationDirPath()+QLatin1String("/../translations") ); // path defaults to app dir.
#endif
#ifdef Q_OS_WIN32
mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), applicationDirPath());
mirallTranslator->load(QLatin1String("mirall_") + locale, applicationDirPath());
#endif
installTranslator(mirallTranslator);

View file

@ -74,6 +74,12 @@ public:
*/
virtual QString defaultClientFolder() const;
/**
* Override to encforce a particular locale, i.e. "de" or "pt_BR"
*/
virtual QString enforcedLocale() const { return QString::null; }
protected:
QIcon themeIcon(const QString& name) const;
Theme() {}