source-sdk-2013
source-sdk-2013 copied to clipboard
Greenlit mods cannot make use of Steam's per-game language feature
The SDK 2013 Base engine uses ISteamUtils::GetSteamUILanguage instead of ISteamApps::GetCurrentGameLanguage.
This forces users to change their Steam language instead of mods being able to utilize the Language tab on the game properties and change just for the specific game.
This can be partially worked around in mod code, but only after the game UI is loaded with Steam's language.
This is what I did for BrainBread 2:
Add this function somewhere:
void LoadGameLocalization(void)
{
if (!steamapicontext)
return;
if (!steamapicontext->SteamApps())
return;
const char *currentSelectedLanguage = steamapicontext->SteamApps()->GetCurrentGameLanguage();
char pchPathToLocalizedFile[80];
// Load default localization:
const char *localizationFiles[] = { "resource/chat_", "resource/gameui_", "resource/hl2_", "resource/replay_", "resource/valve_", "resource/youtube_" };
for (int i = 0; i < _ARRAYSIZE(localizationFiles); ++i)
{
Q_snprintf(pchPathToLocalizedFile, 80, "%s%s.txt", localizationFiles[i], currentSelectedLanguage);
g_pVGuiLocalize->AddFile(pchPathToLocalizedFile, "GAME");
}
// Load game localization:
Q_snprintf(pchPathToLocalizedFile, 80, "resource/brainbread2_%s.txt", currentSelectedLanguage);
if (filesystem->FileExists(pchPathToLocalizedFile, "MOD"))
g_pVGuiLocalize->AddFile(pchPathToLocalizedFile, "MOD");
else
g_pVGuiLocalize->AddFile("resource/brainbread2_english.txt", "MOD");
// Load subtitle localization:
Q_snprintf(pchPathToLocalizedFile, 80, "resource/closecaption_%s.dat", currentSelectedLanguage);
if (filesystem->FileExists(pchPathToLocalizedFile, "MOD"))
engine->ClientCmd_Unrestricted(VarArgs("cc_lang %s\n", currentSelectedLanguage));
else
engine->ClientCmd_Unrestricted("cc_lang english\n");
}
Call the function above at the end of cdll_client_int's CHLClient::PostInit() function.
Remember to replace brainbread2 with your mod's name.
I hope that Valve will add a proper fix for this. Hopefully someone will find this 'workaround' useful.
Thanks for the report -- this will be fixed in the next SDK2013 Base update.
That's great!
I believe this issue is now fixed in the multiplayer/master branch
In my case my Steam language is English, and I've changed the Source SDK Base 2013 Multiplayer language to Polish
running the game with $HOME/.local/share/Steam/steamapps/common/SteamLinuxRuntime_sniper/_v2-entry-point -- ./mod_tf_linux64 started the game in Polish
Closing per the last couple comments.