source-sdk-2013 icon indicating copy to clipboard operation
source-sdk-2013 copied to clipboard

Greenlit mods cannot make use of Steam's per-game language feature

Open psychonic opened this issue 11 years ago • 5 comments

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.

psychonic avatar Jun 12 '14 17:06 psychonic

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.

BerntA avatar Aug 26 '16 19:08 BerntA

Thanks for the report -- this will be fixed in the next SDK2013 Base update.

Nephyrin avatar Aug 26 '16 22:08 Nephyrin

That's great!

BerntA avatar Aug 27 '16 20:08 BerntA

I believe this issue is now fixed in the multiplayer/master branch

halamix2 avatar Feb 27 '25 21:02 halamix2

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

halamix2 avatar Feb 28 '25 00:02 halamix2

Closing per the last couple comments.

kisak-valve avatar Apr 11 '25 12:04 kisak-valve