How to: Localize Code
Unlocalized code uses hard-coded string values. To localize code strings, replace them with calls to GetGlobalResourceObject, which is a method that references localized resources.
To localize code
Add separate resource files to a SharePoint project item: one for the default language and one for each localized language.
To do this, right-click a project item node in Solution Explorer, point to Add, click New Item, and then select Resources File.
Be sure to add the resource file to a SharePoint project item so that the Deployment Type property is available. This property is required later in this procedure.
Give the default language resource file a name of your choice appended with a .resx extension, such as MyAppResources.resx. Use the same base name for each localized resource file, but add the culture ID. For example, name a German localized resource MyAppResources.de-DE.resx.
Open each resource file and add localized strings. Use the same string IDs in each file.
Change the Deployment Type property of each resource file to AppGlobalResource to cause each file to deploy to the server's App_GlobalResources folder.
Leave the Build Action property of each file as Embedded Resource.
Embedded resources are compiled into the project's DLL.
Build the project to create the resource satellite DLLs.
In the Package Designer, click the Advanced tab and add the satellite assembly.
In the Location box, prepend a culture ID folder to the Location path, such as de-DE\Project Item Name.resources.dll.
If your solution does not already reference the System.Web assembly, add a reference to it, and add a directive in your code to System.Web.
Locate all hard-coded strings in your code that are visible to users, such as UI text, errors, and message text. Replace them with a call to the GetGlobalResourceObject method using the following syntax:
HttpContext.GetGlobalResourceObject("Resource File Name", "String ID")
Press F5 to build and run the application.
In SharePoint, change the display language from the default.
The localized strings appear in the application. To display localized resources, the SharePoint server must have a language pack installed that matches the resource file's culture.