views:

19

answers:

2

Hi is it better to create one resource for every asp.net page application. or to create a global resource for all pages? my application has about 100 pages and 200 usercontrols. if i want to create global resource can how can i use this Feature of visual studio that able us to generate resource file automatically from every page with this way :

From Microsoft :

1)Open the page for which you want to create a resource file.

2)Switch to Design View.

3)In the Tools menu, click Generate Local Resource.

thanks for attentions :) . Edition : Does Sharepoint has just one resource file?!

+1  A: 

Use both global and local resource. Put common strings in the Global resource, and page related strings in the Local resource.

I suggest to:

  1. Generate local resource from the page
  2. Move common strings in the global resource

To create a global resource, click on the project, Add new item..., Resource File

onof
How can i move common strings? :)thanks for helping novice programmer :)
shaahin
Common strings are like I put in my reply: Ok, Cancel, ...
XIII
I know.But My challenge is : does move common strings to global resource easy?
shaahin
I heard that sharepoint has just one resource file.does it correct?
shaahin
#shaahin You have to create a key in the global resource, i think there is no other way to move them
onof
+1  A: 

I see most applications split between the 2. The things that come back on most pages like Ok, Cancel, Address, Firstname, ... go in the global one. Specific terms go in the local resources.

In my former application however we deciced to not put it in resources but in the database. We made custom controls which had a translationkey property which mapped to a unique key in the database. The translations were put in the Cache object to keep it as close as possible in reach of the UI parts that needed it. It worked great for us and we needed less deployments since translations could be directly be enhanced in the production database when needed (luckily not that often).

Update due to comment:

public class TranslationLabel : Label, ITranslation
{
    public string TranslationKey { get; set; }
}

In a custom basePage class we looped over the controls collection and took out the ones that implemented the ITranslation interface. Then grab the TranslationKey and look it up in the dictionary retrieved from Cache.

Usage:

<cl:TranslationLabel runat="server" TranslationKey="WarningMessage" />
XIII
Hi XIII :)would you please describe more about that user control or if possible put sample code for me .cheers shaahin.
shaahin
I heard that sharepoint has just one resource file.does it correct?
shaahin
Updated the response. For sharepoint... that could well be, I don't know as I haven't developed for that platform anymore since 2003.
XIII