(77c9efbf8) Display the language names in the respective languages in the initial language selection screen. Closes #1467

This commit is contained in:
Joonas Rikkonen
2019-05-18 21:54:15 +03:00
parent 51e3e8d667
commit f24db4d3ae
5 changed files with 68 additions and 107 deletions
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace Barotrauma
{
@@ -42,6 +43,26 @@ 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)
{
@@ -371,6 +392,25 @@ namespace Barotrauma
.Replace("[Genderpronounreflexive]", Capitalize(Get("PronounReflexiveFemale")));
}
}
static Regex isCJK = new Regex(
@"\p{IsHangulJamo}|" +
@"\p{IsCJKRadicalsSupplement}|" +
@"\p{IsCJKSymbolsandPunctuation}|" +
@"\p{IsEnclosedCJKLettersandMonths}|" +
@"\p{IsCJKCompatibility}|" +
@"\p{IsCJKUnifiedIdeographsExtensionA}|" +
@"\p{IsCJKUnifiedIdeographs}|" +
@"\p{IsHangulSyllables}|" +
@"\p{IsCJKCompatibilityForms}");
/// <summary>
/// Does the string contain symbols from Chinese, Japanese or Korean languages
/// </summary>
public static bool IsCJK(string text)
{
return isCJK.IsMatch(text);
}
#if DEBUG
public static void CheckForDuplicates(string lang)