|
@@ -4,6 +4,8 @@ using PDF_Master.ViewModels.Dialog.BOTA;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
|
|
+using System.Diagnostics.Eventing.Reader;
|
|
|
|
+using System.Globalization;
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Reflection;
|
|
@@ -598,5 +600,87 @@ namespace PDF_Master.Helper
|
|
Numbers = Numbers.OrderBy(a => a).ToList();
|
|
Numbers = Numbers.OrderBy(a => a).ToList();
|
|
Numbers.Reverse();
|
|
Numbers.Reverse();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 获取系统语言列表
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public static CultureInfo[] cultureInfos()
|
|
|
|
+ {
|
|
|
|
+ return CultureInfo.GetCultures(CultureTypes.AllCultures);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 语言缩写获取语言全称
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="languageCode"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public static string LanguageFullName(string languageCode = "en")
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ CultureInfo[] cultures = cultureInfos();
|
|
|
|
+
|
|
|
|
+ CultureInfo matchingCulture = cultures.FirstOrDefault(c => c.TwoLetterISOLanguageName.Equals(languageCode, StringComparison.InvariantCultureIgnoreCase));
|
|
|
|
+
|
|
|
|
+ if (matchingCulture != null)
|
|
|
|
+ {
|
|
|
|
+ string languageFullName = matchingCulture.EnglishName;
|
|
|
|
+ return languageFullName;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return languageCode;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 语言与地区缩写获取语言名字(语言+地区)
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="languageAndcountryCode"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public static string LanguageAndCountryFullName(string languageAndcountryCode = "en-US")
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ CultureInfo culture = CultureInfo.GetCultureInfo(languageAndcountryCode);
|
|
|
|
+ string languageFullName = culture.DisplayName;
|
|
|
|
+ return languageFullName;
|
|
|
|
+ }
|
|
|
|
+ catch (CultureNotFoundException)
|
|
|
|
+ {
|
|
|
|
+ return languageAndcountryCode;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 语言与地区缩写获取语言名字(语言+地区)
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="languageAndcountryCode"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public static string LanguageName(string languageAndcountryCode = "en-US")
|
|
|
|
+ {
|
|
|
|
+ string languageAndcountry = LanguageAndCountryFullName(languageAndcountryCode);
|
|
|
|
+ if (languageAndcountry.Contains("Chinese")) {
|
|
|
|
+ if (languageAndcountry.Contains("Simplified")) {
|
|
|
|
+ return "Chinese";
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return "ChineseTraditional";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if (languageAndcountry.Contains("("))
|
|
|
|
+ {
|
|
|
|
+ string pattern = @"\([^()]*\)"; // 匹配括号以及其中的内容
|
|
|
|
+
|
|
|
|
+ string result = Regex.Replace(languageAndcountry, pattern, string.Empty);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return languageAndcountry;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|