From f77b3b6f715bc7a8b8c576e7f169f10e33952ef9 Mon Sep 17 00:00:00 2001 From: BielBdeLuna <7318.tk@gmail.com> Date: Thu, 6 Nov 2014 16:25:25 +0100 Subject: [PATCH] the engine now supports all the lenguages from steam in sounds and strings --- neo/sys/sys_local.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/neo/sys/sys_local.cpp b/neo/sys/sys_local.cpp index 3e0dc3ad..e355f802 100644 --- a/neo/sys/sys_local.cpp +++ b/neo/sys/sys_local.cpp @@ -295,5 +295,73 @@ const char* Sys_DefaultLanguage() return ID_LANG_ENGLISH; } - return ID_LANG_ENGLISH; + idStr fileName; + + //D3XP: Instead of just loading a single lang file for each language + //we are going to load all files that begin with the language name + //similar to the way pak files work. So you can place english001.lang + //to add new strings to the english language dictionary + idFileList* langFiles; + langFiles = fileSystem->ListFilesTree( "strings", ".lang", true ); + + idStrList langList = langFiles->GetList(); + + // Loop through the list and filter + idStrList currentLangList = langList; + + idStr temp; + for( int i = 0; i < currentLangList.Num(); i++ ) + { + temp = currentLangList[i]; + temp = temp.Right( temp.Length() - strlen( "strings/" ) ); + temp = temp.Left( temp.Length() - strlen( ".lang" ) ); + currentLangList[i] = temp; + } + + if( currentLangList.Num() <= 0 ) + { + // call it English if no lang files exist + sys_lang.SetString( ID_LANG_ENGLISH ); + } + else if( currentLangList.Num() == 1 ) + { + sys_lang.SetString( currentLangList[0] ); + } + else + { + if( currentLangList.Find( ID_LANG_JAPANESE ) ) + { + sys_lang.SetString( ID_LANG_JAPANESE ); + } + else if( currentLangList.Find( ID_LANG_ENGLISH ) ) + { + sys_lang.SetString( ID_LANG_ENGLISH ); + } + else if( currentLangList.Find( ID_LANG_FRENCH ) ) + { + sys_lang.SetString( ID_LANG_FRENCH ); + } + else if( currentLangList.Find( ID_LANG_GERMAN ) ) + { + sys_lang.SetString( ID_LANG_GERMAN ); + } + else if( currentLangList.Find( ID_LANG_ITALIAN ) ) + { + sys_lang.SetString( ID_LANG_GERMAN ); + } + else if( currentLangList.Find( ID_LANG_SPANISH ) ) + { + sys_lang.SetString( ID_LANG_GERMAN ); + } + else + { + sys_lang.SetString( currentLangList[0] ); + } + } + + fileSystem->FreeFileList( langFiles ); + + return sys_lang.GetString();// ID_LANG_ENGLISH; + + }