Last post Oct 24, 2011 09:32 PM by QuestionQueen
Oct 20, 2011 05:13 AM|QuestionQueen|LINK
I have a webapp that I need to be able to view in 5 languages. In my application, there have different regions and customers' user. Authorize user is able to change the resource string value. By different region and different customer, in a form, it could
be has different caption for a label. For example, a label caption for Europe (region) Apple (Customer) is love Europe Apple, a lable caption for Europe Microsoft is love Europe Microsoft, whereas a label caption for America Microsoft is love America Microsoft. I
will give the default value and authorize user is able to change based on their own region and customer's caption. I have to create the custom label control to allow authorize user to change each form's caption if needed. When the caption changed, the resource
string value need to change too.
My issue is what is the best approach to store the different language resources? Database approach or satellite assembly? Database will have the performance issue. If i using the satellite assembly, how do i show all the resource strings in gridview and
enable it to modify and save all the values changed at the same time? When save it, it need to create a new satellite assembly to replace the old one? Should i create the resource file for each region and customer for each language? If i have 2 regions and
5 customers, it will be 10 customers * 5 languages. Total is 50 resx files. It will hard to maintain it. Please help to give the best solution. Thanks for any reply!!
Oct 21, 2011 05:53 PM|rstrahl|LINK
Actually you can use data base resources without much of a performance hit if you use a resource provider. ASP.NET resource providers cache resources in memory so they typically load only once during an application's lifetime. this means database resource
drivers don't add significant overhead.
If you want to use a database driven resource provider here's some info and a sample provider you can use:
+++ Rick ---
Oct 24, 2011 01:24 AM|QuestionQueen|LINK
Hi Rick, thank you so much and appreciate for the information that you provided. Do you have any sample for the satellite assembly approach and regarding the problem that i mentioned?
Thanks for the reply!
Oct 24, 2011 05:07 PM|rstrahl|LINK
If you use Resx resources that is the default provider and it just works. You don't have to do anything special. Just use the Resource Editor to add resources and then reference those resources in your code either via strongly typed resources or via the
ASP.NET provider model (Context.GetLocalResourceObject() COntext.GetGlobalResourceObject). The latter will work the same whether the data comes from Resx resources or from a database provider.
If you want to stick resources into a different assembly you can do that with plain Resx resource. Just create the resources in a separate class libary and either expose the resources via a PUBLIC strongly typed resource class (Internal is default - switch
to public in the Resource Editor to allow resources to be accessible cross-assembly). It's easy to do.
However realize that when you are using resources outside of the ASP.NET resource provider you're not using what ASP.NET internally uses so you get the overhead of both the default Resource Provider and the separate ResourceManager used to access the external
Resx resources. ASP.NET Resource Providers tend to be very efficient because they agressively cache resources where resource manager access often has to reload resources. And since you can't turn off the default resource provider both will always be active
side by side so there's more overhead in doing both.
Lots of options obviously :-) I would stick with what ASP.NET uses natively (Resource Providers) because that's what ASP.NET uses natively and what was designed for that usage scenario. Of course it does depend on what you're building too. If you're building
WebForms apps - definitely stick with Resource Provider. If you're building custom handlers or are using MVC then raw resources make more sense although the resource provider will still work as well for explicit resource retrieval.
Oct 24, 2011 09:32 PM|QuestionQueen|LINK
Thanks for the answer!