#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/lyxalgo.h" // sorted
+#include "support/Messages.h"
#include "support/os.h"
#include "support/Package.h"
QCoreApplication::setOrganizationDomain("lyx.org");
QCoreApplication::setApplicationName(app_name + "-" + lyx_version);
+ // Install translator for GUI elements.
+ installTranslator(&d->qt_trans_);
+
// FIXME: quitOnLastWindowClosed is true by default. We should have a
// lyxrc setting for this in order to let the application stay resident.
// But then we need some kind of dock icon, at least on Windows.
// FIXME: Do we need a lyxrc setting for this on Mac? This behaviour
// seems to be the default case for applications like LyX.
setQuitOnLastWindowClosed(false);
+
+ // This allows to translate the strings that appear in the LyX menu.
+ /// A translator suitable for the entries in the LyX menu.
+ /// Only needed with Qt/Mac.
+ installTranslator(new MenuTranslator(this));
#endif
#ifdef Q_WS_X11
QApplication::setDoubleClickInterval(300);
#endif
- // install translation file for Qt built-in dialogs
- QString language_name = QString("qt_") + QLocale::system().name();
-
- // language_name can be short (e.g. qt_zh) or long (e.g. qt_zh_CN).
- // Short-named translator can be loaded from a long name, but not the
- // opposite. Therefore, long name should be used without truncation.
- // c.f. http://doc.trolltech.com/4.1/qtranslator.html#load
- if (d->qt_trans_.load(language_name,
- QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
- {
- installTranslator(&d->qt_trans_);
- // even if the language calls for RtL, don't do that
- setLayoutDirection(Qt::LeftToRight);
- LYXERR(Debug::LOCALE, "Successfully installed Qt translations for locale "
- << language_name);
- } else
- LYXERR(Debug::LOCALE, "Could not find Qt translations for locale "
- << language_name);
-
-#ifdef Q_WS_MACX
- // This allows to translate the strings that appear in the LyX menu.
- /// A translator suitable for the entries in the LyX menu.
- /// Only needed with Qt/Mac.
- installTranslator(new MenuTranslator(this));
-#endif
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(onLastWindowClosed()));
using namespace lyx::graphics;
void GuiApplication::resetGui()
{
// Set the language defined by the user.
- setRcGuiLanguage();
+ setGuiLanguage();
// Read menus
if (!readUIFile(toqstr(lyxrc.ui_file)))
d->menus_.fillMenuBar(d->global_menubar_, 0, true);
QHash<int, GuiView *>::iterator it;
- for (it = d->views_.begin(); it != d->views_.end(); ++it)
- (*it)->resetDialogs();
+ for (it = d->views_.begin(); it != d->views_.end(); ++it) {
+ GuiView * gv = *it;
+ gv->setLayoutDirection(layoutDirection());
+ gv->resetDialogs();
+ }
dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
}
}
-void GuiApplication::execBatchCommands()
+void GuiApplication::setGuiLanguage()
{
// Set the language defined by the user.
setRcGuiLanguage();
+ QString const default_language = toqstr(Messages::defaultLanguage());
+ LYXERR(Debug::LOCALE, "Tring to set default locale to: " << default_language);
+ QLocale const default_locale(default_language);
+ QLocale::setDefault(default_locale);
+
+ // install translation file for Qt built-in dialogs
+ QString const language_name = QString("qt_") + default_locale.name();
+
+ // language_name can be short (e.g. qt_zh) or long (e.g. qt_zh_CN).
+ // Short-named translator can be loaded from a long name, but not the
+ // opposite. Therefore, long name should be used without truncation.
+ // c.f. http://doc.trolltech.com/4.1/qtranslator.html#load
+ if (!d->qt_trans_.load(language_name,
+ QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
+ LYXERR(Debug::LOCALE, "Could not find Qt translations for locale "
+ << language_name);
+ } else {
+ LYXERR(Debug::LOCALE, "Successfully installed Qt translations for locale "
+ << language_name);
+ }
+
+ switch (default_locale.language()) {
+ case QLocale::Arabic :
+ case QLocale::Hebrew :
+ case QLocale::Persian :
+ case QLocale::Urdu :
+ setLayoutDirection(Qt::RightToLeft);
+ break;
+ default:
+ setLayoutDirection(Qt::LeftToRight);
+ }
+}
+
+
+void GuiApplication::execBatchCommands()
+{
+ setGuiLanguage();
+
// Read menus
if (!readUIFile(toqstr(lyxrc.ui_file)))
// Gives some error box here.