public string GetText(string resourceName, string uiCultureTab = null, params Object[] list) { var rc = "[not found]"; try { if (SupportedCultures != null) { if (_rm == null) { var baseName = GetResourcesAsm().GetName().Name + ".Properties.Resources"; _rm = new ResourceManager(baseName, GetResourcesAsm()); } var cookies = new MxCookies(HttpContextAccessor); if (SupportedCultures.IsSupported(uiCultureTab) == false) { uiCultureTab = SupportedCultures.GetUiCultureTab(cookies.GetValue(MxSupportedCultures.CookieName)); } var uiCultureInfo = SupportedCultures.GetCultureInfo(uiCultureTab); if (uiCultureInfo != null) { var res = _rm?.GetString(resourceName ?? "NotFound", uiCultureInfo) ?? "[Not Found]"; rc = string.Format(uiCultureInfo, res, list); } } } catch (Exception e) { // ReSharper disable once UnusedVariable var msg = e.Message; //ignore } return(rc); }
public bool SetCurrentCulture(string cultureTab = null, string uiCultureTab = null) { var rc = false; try { if (SupportedCultures.IsSupported(cultureTab)) { Thread.CurrentThread.CurrentCulture = SupportedCultures.GetCultureInfo(cultureTab); } if (SupportedCultures.IsSupported(uiCultureTab)) { Thread.CurrentThread.CurrentUICulture = SupportedCultures.GetCultureInfo(uiCultureTab); } rc = true; } catch (Exception) { //ignore } return(rc); }