mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 14:31:24 +12:00
Qt: use current locale for last played in gamelist
This also sets the basic groundwork for Qt translations
This commit is contained in:
parent
1759d6d90a
commit
d47a8b49a4
4 changed files with 71 additions and 7 deletions
|
@ -35,6 +35,8 @@ void gui_application::Init()
|
|||
{
|
||||
setWindowIcon(QIcon(":/rpcs3.ico"));
|
||||
|
||||
LoadLanguage(QLocale(QLocale::English).name());
|
||||
|
||||
m_emu_settings.reset(new emu_settings());
|
||||
m_gui_settings.reset(new gui_settings());
|
||||
m_persistent_settings.reset(new persistent_settings());
|
||||
|
@ -54,9 +56,6 @@ void gui_application::Init()
|
|||
// Create connects to propagate events throughout Gui.
|
||||
InitializeConnects();
|
||||
|
||||
// As per QT recommendations to avoid conflicts for POSIX functions
|
||||
std::setlocale(LC_NUMERIC, "C");
|
||||
|
||||
if (m_main_window)
|
||||
{
|
||||
m_main_window->Init();
|
||||
|
@ -77,6 +76,46 @@ void gui_application::Init()
|
|||
#endif
|
||||
}
|
||||
|
||||
void gui_application::SwitchTranslator(QTranslator& translator, const QString& filename)
|
||||
{
|
||||
// remove the old translator
|
||||
removeTranslator(&translator);
|
||||
|
||||
// load the new translator
|
||||
if (translator.load(QLocale(QLocale::English), filename))
|
||||
{
|
||||
installTranslator(&translator);
|
||||
}
|
||||
}
|
||||
|
||||
void gui_application::LoadLanguage(const QString& language)
|
||||
{
|
||||
if (m_language == language)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_language = language;
|
||||
|
||||
const QLocale locale = QLocale(language);
|
||||
QLocale::setDefault(locale);
|
||||
|
||||
// Idk if this is overruled by the QLocale default, so I'll change it here just to be sure.
|
||||
// As per QT recommendations to avoid conflicts for POSIX functions
|
||||
std::setlocale(LC_NUMERIC, "C");
|
||||
|
||||
// TODO: implement once we decided to enable translations
|
||||
//SwitchTranslator(m_translator, QString("TranslationExample''%1.qm").arg(language));
|
||||
//SwitchTranslator(m_translator_qt, QString("qt_%1.qm").arg(language));
|
||||
|
||||
if (m_main_window)
|
||||
{
|
||||
m_main_window->RepaintGui();
|
||||
}
|
||||
|
||||
gui_log.notice("Current language changed to %s (%s)", QLocale::languageToString(locale.language()).toStdString(), language.toStdString());
|
||||
}
|
||||
|
||||
void gui_application::InitializeConnects()
|
||||
{
|
||||
connect(this, &gui_application::OnEmulatorRun, this, &gui_application::StartPlaytime);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue