Michael
Michael

Reputation: 13614

Manage resource files on production

I working on site internationalization I use mvc5.

The text in diffrent languages is stored in Resources files:

enter image description here

on the view when I change the languages(english, spanish, arabic) it works greate.

But the problem is that I need to publish solution and to move it to production server.While in production server on runtime might be needed to change text in resource fils on the runtime.

So my quetion is it possible to change resource files without recompiling application?

Upvotes: 0

Views: 149

Answers (1)

Minus
Minus

Reputation: 729

If I understand correctly, if you want to add/remove/update content of resources files, you need to recompile them.

Otherwise if you are looking to switch between resources files, as @JamesP showed, you just have to set the current thread's culture on the fly.

Make sure to do it in a BaseController, and override some base method ( I use protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state) ). So it will be set before any controler actions. It must be set on every call since MVC is on one thread by call basis.

for a complete working example, you could check this article : http://afana.me/archive/2011/01/14/aspnet-mvc-internationalization.aspx/

Upvotes: 1

Related Questions