mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
read language from Language.ini file
to avoid having to ship a whole ja2.ini for languages that currently don't command-line /language:german still works, but INI file is prioritized format: ``` [Language] LANGUAGE = ITALIAN ```
This commit is contained in:
committed by
majcosta
parent
d03989051a
commit
8d1877d26d
@@ -8,8 +8,10 @@
|
|||||||
#include "Campaign Types.h"
|
#include "Campaign Types.h"
|
||||||
#include "environment.h"
|
#include "environment.h"
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
#define GAME_INI_FILE "Ja2.ini"
|
#define GAME_INI_FILE "Ja2.ini"
|
||||||
|
|
||||||
|
constexpr std::string_view LANGUAGE_INI_FILE{"Language.ini"};
|
||||||
//If you add any options, MAKE sure you add the corresponding string to the Options Screen string array.
|
//If you add any options, MAKE sure you add the corresponding string to the Options Screen string array.
|
||||||
// look up : zOptionsScreenHelpText , zOptionsToggleText
|
// look up : zOptionsScreenHelpText , zOptionsToggleText
|
||||||
//Also, define its initialization and add its load/save to INI lines in : InitGameSettings() , SaveGameSettings() , LoadGameSettings()
|
//Also, define its initialization and add its load/save to INI lines in : InitGameSettings() , SaveGameSettings() , LoadGameSettings()
|
||||||
|
|||||||
+11
-4
@@ -949,12 +949,19 @@ void GetRuntimeSettings( )
|
|||||||
SGP_THROW_IFFALSE( setlocale(LC_ALL, loc.utf8().c_str()), _BS(L"invalid locale : ") << loc << _BS::wget );
|
SGP_THROW_IFFALSE( setlocale(LC_ALL, loc.utf8().c_str()), _BS(L"invalid locale : ") << loc << _BS::wget );
|
||||||
}
|
}
|
||||||
|
|
||||||
vfs::String language = oProps.getStringProperty("Ja2 Settings", L"LANGUAGE");
|
vfs::PropertyContainer langProps;
|
||||||
if(!language.empty())
|
langProps.initFromIniFile(std::string{LANGUAGE_INI_FILE});
|
||||||
|
auto langIni = langProps.getStringProperty("Language", L"LANGUAGE");
|
||||||
|
auto langCli = oProps.getStringProperty("Ja2 Settings", L"LANGUAGE");
|
||||||
|
std::string language{};
|
||||||
|
if(!langCli.empty())
|
||||||
{
|
{
|
||||||
std::string languageName = language.utf8();
|
language = langCli.utf8();
|
||||||
SetLanguageFromName(languageName);
|
|
||||||
}
|
}
|
||||||
|
if (!langIni.empty()) {
|
||||||
|
language = langIni.utf8();
|
||||||
|
}
|
||||||
|
SetLanguageFromName(language);
|
||||||
|
|
||||||
// Rebind every language table pointer to the resolved g_lang. Unconditional:
|
// Rebind every language table pointer to the resolved g_lang. Unconditional:
|
||||||
// with no LANGUAGE key this binds the build default, matching the static
|
// with no LANGUAGE key this binds the build default, matching the static
|
||||||
|
|||||||
Reference in New Issue
Block a user