timberhill
timberhill

Reputation: 67

resx localization in mvc 3

I have three resource files in App_GlobalResources for a view:

ConditionsLabels.en.resx
ConditionsLabels.ua.resx
ConditionsLabels.ru.resx

But I can't get any value. I specified custom namespaces (ViewRes), but in the view autocomplete suggests the only variant @ViewRes.ConditionsLabels_ua. (it's class)

How can I use that?

Upvotes: 2

Views: 685

Answers (1)

McGarnagle
McGarnagle

Reputation: 102723

Don't use App_GlobalResources for MVC projects. Instead, place your .resx files in a standard folder (say, "Resources" or whatever). Next, select the .resx files in Visual Studio and change the following properties:

Custom Tool: PublicResXFileCodeGenerator
Custom Tool Namespace: Resources

Now you should be able to access your resources normally using Resources.MyResource.String1, etc.

Upvotes: 3

Related Questions