Reputation: 12851
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?!
Upvotes: 3
Views: 1416
Reputation: 16613
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" />
Upvotes: 2
Reputation: 17377
Use both global and local resource. Put common strings in the Global resource, and page related strings in the Local resource.
I suggest to:
To create a global resource, click on the project, Add new item..., Resource File
Upvotes: 1