Explain the steps to create and implement Satellite Assemblies.
Satellite assemblies are resource assemblies specific to language/culture. Different resource files are created for different languages/cultures and then the needed one is loaded based on the user.
1. Create a new web application
2. Drag 2 label controls, a dropdownlist and a button control. Add 2 items to the drop down, en-US and fr-FR.
3. Add a new folder called resources and add 2 resource assembly files in it.,
e.g.: res1.resx and res1.fr-FR.resx In res1.resx, add a key “Welcome” and value as “Hello there”. In res1.fr-FR.resx, add a key called “Welcome” and value as “Bon Journe”.
4. Generate their resource files by using the resgen command for each of these resource files and keep them in the App_GlobalResources folder.
5. On button’s click even at the following code:
Session["language"]=dropdownlist1.SelectedItem .Text ;
Response.Redirect ("Webform2.aspx");
7. Add a label inWebform2.aspx. In page load event of Webform2.aspx.cs add the following code.
System.Resources.ResourceManager resourceManager
=ResourceManager.CreateFileBasedResourceManager("res1",Server.MapPath("Resources")+Path.DirectorySeparatorChar , null);
string getLanguage = Session["language"].ToString ();
CultureInfo cultureInfo=new CultureInfo(getLanguage);
Label1.Text=resourceManager.GetString ("Welcome",cultureInfo);
When you execute the Webform1.aspx, choose one of the English or French option from the dropdownlist and hit the button. It should display welcome message based on the chosen option from the dropdownlist.