private static string getTranslat(string name, CultureLanguages culture) { string translat = null; if (culture?.Translates?.TryGetValue(name, out translat) == true) { return(translat); } else { foreach (var item in culture?.TranslateRegexs ?? new TranslateRegexs[] { }) { if (System.Text.RegularExpressions.Regex.IsMatch(name, item.Pattern)) { var timeoutInSecondsGroups = System.Text.RegularExpressions.Regex.Match(name, item.Pattern).Groups; var t = item.Translate; foreach (var n in item.Names) { t = t.Replace($"{{{n}}}", timeoutInSecondsGroups[n].Value); } return(t); } } } return(null); }
public static void AddCultureLanguages(CultureLanguages culture) { keyValues.AddOrUpdate(culture.Culture, culture, (name, oldCulture) => culture); }
/// <summary> /// 添加翻译对象 /// </summary> /// <param name="func"></param> /// <returns></returns> public ManagementPagesOptions TranslateCulture(CultureLanguages culture) { JsonHangfireLanguage.AddCultureLanguages(culture); return(this); }