| 20 | using namespace Lemon; |
| 21 | |
| 22 | auto LemonBaseApplication::Initialize() -> bool { |
| 23 | QString errorMessage; |
| 24 | bool canContinue; |
| 25 | const auto hasError = parseCommandLine(&canContinue, &errorMessage); |
| 26 | if (hasError) { |
| 27 | LOG("Command line: " GEN_PAIR(errorMessage)); |
| 28 | if (! canContinue) { |
| 29 | LOG("Fatal Error, LemonLime cannot continue."); |
| 30 | return false; |
| 31 | } else { |
| 32 | LOG("Non-fatal error, LemonLime will continue starting up."); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | // Load Translations |
| 37 | Settings *settings = new Settings; |
| 38 | settings->loadSettings(); |
| 39 | LemonLimeTranslator = std::make_unique<LemonTranslator>(); |
| 40 | const auto allTranslations = LemonLimeTranslator->GetAvailableLanguages(); |
| 41 | const auto osLanguage = QLocale::system().name(); |
| 42 | if (! allTranslations.contains(settings->getUiLanguage())) { |
| 43 | // If we need to reset the language. |
| 44 | if (allTranslations.contains(osLanguage)) { |
| 45 | settings->setUiLanguage(osLanguage); |
| 46 | } else if (! allTranslations.isEmpty()) { |
| 47 | settings->setUiLanguage(allTranslations.first()); |
| 48 | } |
| 49 | } |
| 50 | LemonLimeTranslator->InstallTranslation(settings->getUiLanguage()); |
| 51 | |
| 52 | return true; |
| 53 | } |
| 54 | |
| 55 | auto LemonBaseApplication::parseCommandLine(bool *canContinue, QString *errorMessage) -> bool { |
| 56 | *canContinue = true; |
no test coverage detected