idTech4.idSystem.InitLanguageDict C# (CSharp) Method

InitLanguageDict() private method

private InitLanguageDict ( ) : void
return void
		private void InitLanguageDict()
		{
			idE.Language.Clear();

			// 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 files = idE.FileSystem.GetFiles("strings", ".lang", true);
			string[] langFiles = files.Files;

			// let it be set on the command line - this is needed because this init happens very early
			StartupVariable("sys_lang", false);

			string langName = idE.CvarSystem.GetString("sys_lang");

			// loop through the list and filter
			string[] currentLanguageList = langFiles.Where(c => c.StartsWith(langName)).ToArray();

			if(currentLanguageList.Length == 0)
			{
				// reset cvar to default and try to load again
				idE.CmdSystem.BufferCommandText(Execute.Now, "reset sys_lang");

				langName = idE.CvarSystem.GetString("sys_lang");
				currentLanguageList = langFiles.Where(c => c.StartsWith(langName)).ToArray();
			}

			foreach(string lang in currentLanguageList)
			{
				idE.Language.Load(Path.Combine(files.BaseDirectory, lang), false);
			}

			idConsole.Warning("TODO: Sys_InitScanTable");
		}