Lasse Edsvik
Lasse Edsvik

Reputation: 9298

Get current culture in MVC 3 application

I'm trying to create a small app that contains errormessages in database, so they'll be easy to edit etc from a webpage.

So my question is what do I need to put in my class, the "...typeof(MyCustomErrorApp)" to get the current culture? What needs to be derived (?) from etc?

/Lasse

Upvotes: 0

Views: 2943

Answers (2)

Lukáš Novotný
Lukáš Novotný

Reputation: 9052

I assume you are talking about validation attributes - those are loading resources from static class using reflection. You can simply target any class with static properties:

public class DBErrorResources
{
    public static string Required
    {
        get { return DB.FetchErrorMesssage(CultureInfo.CurrentUICulture); }
    }
}

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1039428

The ASP.NET resource provider is extensible. So you could write your custom ResourceProviderFactory.

Upvotes: 1

Related Questions