Browse Source

engine: fix audio language setting

pull/122/merge
nillerusr 2 years ago
parent
commit
5912845f29
  1. 14
      engine/cl_main.cpp
  2. 9
      engine/common.cpp

14
engine/cl_main.cpp

@ -2738,6 +2738,7 @@ static ConCommand startupmenu( "startupmenu", &CL_CheckToDisplayStartupMenus, "O
ConVar cl_language( "cl_language", "english", FCVAR_USERINFO, "Language (from HKCU\\Software\\Valve\\Steam\\Language)" ); ConVar cl_language( "cl_language", "english", FCVAR_USERINFO, "Language (from HKCU\\Software\\Valve\\Steam\\Language)" );
void CL_InitLanguageCvar() void CL_InitLanguageCvar()
{ {
Msg("CL_InitLanguageCvar\n");
if ( Steam3Client().SteamApps() ) if ( Steam3Client().SteamApps() )
{ {
cl_language.SetValue( Steam3Client().SteamApps()->GetCurrentGameLanguage() ); cl_language.SetValue( Steam3Client().SteamApps()->GetCurrentGameLanguage() );
@ -2747,15 +2748,22 @@ void CL_InitLanguageCvar()
char *szLang = getenv("LANG"); char *szLang = getenv("LANG");
if ( CommandLine()->CheckParm( "-language" ) ) if ( CommandLine()->CheckParm( "-language" ) )
{
cl_language.SetValue( CommandLine()->ParmValue( "-language", "english") ); cl_language.SetValue( CommandLine()->ParmValue( "-language", "english") );
return;
}
else if( szLang ) else if( szLang )
{ {
ELanguage lang = PchLanguageICUCodeToELanguage(szLang, k_Lang_English); ELanguage lang = PchLanguageICUCodeToELanguage(szLang, k_Lang_English);
const char *szShortLang = GetLanguageShortName(lang); const char *szShortLang = GetLanguageShortName(lang);
cl_language.SetValue( szShortLang ); if( Q_strncmp(szShortLang, "none", 4) != 0 )
{
cl_language.SetValue( szShortLang );
return;
}
} }
else
cl_language.SetValue( "english" ); cl_language.SetValue( "english" );
} }
} }

9
engine/common.cpp

@ -900,11 +900,20 @@ void COM_InitFilesystem( const char *pFullModPath )
} }
else else
{ {
char *szLang = getenv("LANG");
// still allow command line override even when not running steam // still allow command line override even when not running steam
if (CommandLine()->CheckParm("-audiolanguage")) if (CommandLine()->CheckParm("-audiolanguage"))
{ {
Q_strncpy(language, CommandLine()->ParmValue("-audiolanguage", "english"), sizeof( language ) - 1); Q_strncpy(language, CommandLine()->ParmValue("-audiolanguage", "english"), sizeof( language ) - 1);
} }
else if( szLang )
{
ELanguage lang = PchLanguageICUCodeToELanguage(szLang, k_Lang_English);
const char *szShortLang = GetLanguageShortName(lang);
if( Q_strncmp(szShortLang, "none", 4) != 0 )
Q_strncpy(language, szShortLang, sizeof( language ) - 1);
}
} }
if ( ( Q_strlen(language) > 0 ) && ( Q_stricmp(language, "english") ) ) if ( ( Q_strlen(language) > 0 ) && ( Q_stricmp(language, "english") ) )

Loading…
Cancel
Save