Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public string GetUiCultureTab()
        {
            var cookies = new MxCookies(HttpContextAccessor);

            return(SupportedCultures.GetUiCultureTab(cookies.GetValue(MxSupportedCultures.CookieName)));
        }