(2e0e45e1f) Updated: Localization
This commit is contained in:
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -43,26 +42,6 @@ namespace Barotrauma
|
||||
GetTextFilesRecursive(subDir, ref list);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the language in the respective language
|
||||
/// </summary>
|
||||
public static string GetTranslatedLanguageName(string language)
|
||||
{
|
||||
if (!textPacks.ContainsKey(language))
|
||||
{
|
||||
return language;
|
||||
}
|
||||
|
||||
foreach (var textPack in textPacks[language])
|
||||
{
|
||||
if (textPack.Language == language)
|
||||
{
|
||||
return textPack.TranslatedName;
|
||||
}
|
||||
}
|
||||
return language;
|
||||
}
|
||||
|
||||
public static void LoadTextPacks(IEnumerable<ContentPackage> selectedContentPackages)
|
||||
{
|
||||
@@ -101,26 +80,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ContainsTag(string textTag)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textTag)) { return false; }
|
||||
|
||||
if (!textPacks.ContainsKey(Language))
|
||||
{
|
||||
DebugConsole.ThrowError("No text packs available for the selected language (" + Language + ")! Switching to English...");
|
||||
Language = "English";
|
||||
if (!textPacks.ContainsKey(Language))
|
||||
{
|
||||
throw new Exception("No text packs available in English!");
|
||||
}
|
||||
}
|
||||
foreach (TextPack textPack in textPacks[Language])
|
||||
{
|
||||
if (textPack.Get(textTag) != null) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string Get(string textTag, bool returnNull = false, string fallBackTag = null)
|
||||
{
|
||||
if (!textPacks.ContainsKey(Language))
|
||||
@@ -132,6 +91,8 @@ namespace Barotrauma
|
||||
throw new Exception("No text packs available in English!");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (TextPack textPack in textPacks[Language])
|
||||
{
|
||||
@@ -155,13 +116,7 @@ namespace Barotrauma
|
||||
foreach (TextPack textPack in textPacks["English"])
|
||||
{
|
||||
string text = textPack.Get(textTag);
|
||||
if (text != null)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.NewMessage("Text \"" + textTag + "\" not found for the language \"" + Language + "\". Using the English text \"" + text + "\" instead.");
|
||||
#endif
|
||||
return text;
|
||||
}
|
||||
if (text != null) return text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,6 +367,42 @@ namespace Barotrauma
|
||||
return isCJK.IsMatch(text);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
public static void CheckForDuplicates(string lang)
|
||||
{
|
||||
if (!textPacks.ContainsKey(lang))
|
||||
{
|
||||
DebugConsole.ThrowError("No text packs available for the selected language (" + lang + ")!");
|
||||
return;
|
||||
}
|
||||
|
||||
int packIndex = 0;
|
||||
foreach (TextPack textPack in textPacks[lang])
|
||||
{
|
||||
textPack.CheckForDuplicates(packIndex);
|
||||
packIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteToCSV()
|
||||
{
|
||||
string lang = "English";
|
||||
|
||||
if (!textPacks.ContainsKey(lang))
|
||||
{
|
||||
DebugConsole.ThrowError("No text packs available for the selected language (" + lang + ")!");
|
||||
return;
|
||||
}
|
||||
|
||||
int packIndex = 0;
|
||||
foreach (TextPack textPack in textPacks[lang])
|
||||
{
|
||||
textPack.WriteToCSV(packIndex);
|
||||
packIndex++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
public static void CheckForDuplicates(string lang)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user