370 |
370 |
371 QString cc = settings.value("misc/locale", QString()).toString(); |
371 QString cc = settings.value("misc/locale", QString()).toString(); |
372 if (cc.isEmpty()) |
372 if (cc.isEmpty()) |
373 { |
373 { |
374 cc = QLocale::system().name(); |
374 cc = QLocale::system().name(); |
|
375 qDebug("Detected system locale: %s", qPrintable(cc)); |
375 |
376 |
376 // Fallback to current input locale if "C" locale is returned |
377 // Fallback to current input locale if "C" locale is returned |
377 if(cc == "C") |
378 if(cc == "C") |
378 cc = HWApplication::inputMethod()->locale().name(); |
379 cc = HWApplication::inputMethod()->locale().name(); |
379 } |
380 } |
380 qDebug("Frontend uses locale: %s", qPrintable(cc)); |
381 else |
381 |
382 { |
382 // Load locale files into translators |
383 qDebug("Configured frontend locale: %s", qPrintable(cc)); |
383 if (!TranslatorHedgewars.load(QString("hedgewars_%1").arg(cc), QString("physfs://Locale"))) |
384 } |
384 qWarning("Failed to install Hedgewars translation (%s)", qPrintable(cc)); |
385 QLocale::setDefault(cc); |
385 if (!TranslatorQt.load(QString("qt_%1").arg(cc), QString(QLibraryInfo::location(QLibraryInfo::TranslationsPath)))) |
386 QString defaultLocaleName = QLocale().name(); |
386 qWarning("Failed to install Qt translation (%s)", qPrintable(cc)); |
387 qDebug("Frontend uses locale: %s", qPrintable(defaultLocaleName)); |
387 app.installTranslator(&TranslatorHedgewars); |
388 |
388 app.installTranslator(&TranslatorQt); |
389 if (defaultLocaleName != "C") |
389 app.setLayoutDirection(QLocale(cc).textDirection()); |
390 { |
|
391 // Load locale files into translators |
|
392 if (!TranslatorHedgewars.load(QLocale(), "hedgewars", "_", QString("physfs://Locale"))) |
|
393 qWarning("Failed to install Hedgewars translation (%s)", qPrintable(defaultLocaleName)); |
|
394 if (!TranslatorQt.load(QLocale(), "qt", "_", QString(QLibraryInfo::location(QLibraryInfo::TranslationsPath)))) |
|
395 qWarning("Failed to install Qt translation (%s)", qPrintable(defaultLocaleName)); |
|
396 app.installTranslator(&TranslatorHedgewars); |
|
397 app.installTranslator(&TranslatorQt); |
|
398 } |
|
399 app.setLayoutDirection(QLocale().textDirection()); |
390 } |
400 } |
391 |
401 |
392 #ifdef _WIN32 |
402 #ifdef _WIN32 |
393 // Win32 registry setup (used for external software detection etc. |
403 // Win32 registry setup (used for external software detection etc. |
394 // don't set it if running in "portable" mode with a custom config dir) |
404 // don't set it if running in "portable" mode with a custom config dir) |