aspnet-internationalization icon indicating copy to clipboard operation
aspnet-internationalization copied to clipboard

Validation messages are not localised

Open JakeGinnivan opened this issue 12 years ago • 0 comments

For instance 'Required' error messages

Putting this into my controller fixes it ([LanguageFilter] does not help)

    protected override void Initialize(RequestContext requestContext)
    {
        var culture = requestContext.HttpContext.Request.Cookies["_culture"];
        if (culture != null)
        {
            SetCulture(culture.Value);
        }
        base.Initialize(requestContext);
    }

    private void SetCulture(string culture)
    {
        culture = culture ?? "en";
        ViewBag.Culture = culture;
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
        Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(culture);
    }

JakeGinnivan avatar Apr 11 '13 04:04 JakeGinnivan