hzqst / MetaHookSv

MetaHook (https://github.com/nagist/metahook) porting for SvEngine (GoldSrc engine modified by Sven-Coop)
MIT License
148 stars 37 forks source link

[CaptionMod] TODO: multi-language support for Sven Co-op #92

Closed hzqst closed 3 years ago

hzqst commented 3 years ago
   // When Steam isn't running we can't get the language info... 
   if ( SteamApps() )
   {
      const int nAppID = engine->GetAppID();
      SteamApps()->GetAppData( nAppID, "language", szCurrentLanguage, sizeof(szCurrentLanguage) );
      SteamApps()->GetAppData( nAppID, "languages", szAvailableLanguages, sizeof( szAvailableLanguages ) );
   }

        modinfo = new KeyValues("ModInfo");
        if ( modinfo->LoadFromFile( g_pFileSystem, "gameinfo.txt" ) )
        {
            const int nSteamAppId = modinfo->FindKey( "FileSystem" )->GetInt("SteamAppId", 215 );
            ELanguage eAudioLanguage = k_Lang_English;
            char szAudioLanguageRegKey[MAX_PATH];
            long lRegValue;

            // Construct registry key path
            V_strncpy( szAudioLanguageRegKey, "Software\\Valve\\Steam\\Apps\\", sizeof( szAudioLanguageRegKey ) );
            itoa( nSteamAppId, &(szAudioLanguageRegKey[strlen( szAudioLanguageRegKey )]), 10 );
            Sys_GetRegKeyValueInt( szAudioLanguageRegKey, "language", &lRegValue, k_Lang_English );
            eAudioLanguage = (ELanguage)lRegValue;

    if ( IsPC() )
    {
        // get Steam client language
        char language[128];
        language[0] = 0;
        Sys_GetRegKeyValue( "Software\\Valve\\Steam", "Language", language, sizeof(language), "" );
        if ( ( Q_strlen(language) > 0 ) && ( Q_stricmp(language, "english") ) )
        {
            initInfo.m_pLanguage = language;
        }
    }

vgui::g_pSystem->GetRegistryString( "HKEY_CURRENT_USER\\Software\\Valve\\Steam\\Language", language, sizeof(language)-1 );
qabRieL99 commented 3 years ago

Is it possible to detect the files in the caption mod folder? Let's say there are two dictionary files;

Maybe we can have a dropdownbox to change the language?

hzqst commented 3 years ago

Is it possible to detect the files in the caption mod folder? Let's say there are two dictionary files;

  • dictionary_english
  • dictionary_german

Maybe we can have a dropdownbox to change the language?

You can't change language dynamically in GoldSrc while game is running. vgui2 in GoldSrc doesn't support re-initializing localized strings at runtime.

dictionary_%language%.txt is supported now in 1da890604419d1abb9ef10f2d4372bf2776b29bd

Two commandargs has been added in baa1f90dca8120c33b4b731347de3466df58c43d : -steamlang : use Steam language as engine and vgui2 language, ignore game language setting in Steam's game config panel. for Sven Co-op, it always uses Steam language as engine and vgui2 language no matter if -steamlang is added or not. -forcelang [language] : force engine and vgui2 to use [language], ignore game language setting in Steam's game config panel.

Tooltips : engine language : engine and filesystem will search files in SteamApps/Half-Life/[gamedir]_[language]/ at higher priority. vgui2 language : vgui2 will load localtization files whoose name is filename_[language].txt