MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / defaultLanguage

Method defaultLanguage

src/Engine/Game.cpp:593–633  ·  view source on GitHub ↗

* Loads the most appropriate language * given current system and game options. */

Source from the content-addressed store, hash-verified

591 * given current system and game options.
592 */
593void Game::defaultLanguage()
594{
595 std::string defaultLang = "en-US";
596 // No language set, detect based on system
597 if (Options::language.empty())
598 {
599 std::string locale = CrossPlatform::getLocale();
600 std::string lang = locale.substr(0, locale.find_first_of('-'));
601 // Try to load full locale
602 try
603 {
604 loadLanguage(locale);
605 }
606 catch (std::exception)
607 {
608 // Try to load language locale
609 try
610 {
611 loadLanguage(lang);
612 }
613 // Give up, use default
614 catch (std::exception)
615 {
616 loadLanguage(defaultLang);
617 }
618 }
619 }
620 else
621 {
622 // Use options language
623 try
624 {
625 loadLanguage(Options::language);
626 }
627 // Language not found, use default
628 catch (std::exception)
629 {
630 loadLanguage(defaultLang);
631 }
632 }
633}
634
635/**
636 * Initializes the audio subsystem.

Callers 2

btnYesClickMethod · 0.80
loadMethod · 0.80

Calls 2

getLocaleFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected