Sharepoint – Localization

http://msdn.microsoft.com/en-us/library/ee696750.aspx

To localize a solution, you remove hard-coded strings from the code and abstract them into resource files. A Resource file is an XML-based file with a .resx extension. The resource file contains the translated versions of the strings used in your solution.

There are three kinds of resource files:
(1) default — Also known as a fallback resource, default resource files contain strings localized for the default culture, such as English (Invariant Language (Invariant Country))
(2) language-neutral — A resource file that contains strings localized for a language, but not a specific culture. For example, “fr” for French.
(3) language-specific — A resource file that contains strings localized for a language
and a culture. For example, “fr-CA” for French Canadian.

To specify default resource files
in Visual Studio SharePoint projects, select Invariant Language (Invariant Country) in the culture list of the Add Resource dialog box when you add a resource file. 

Invariant Language is the default language/culture.


Add more resource files for other different languages/culture

You need to use the same ID for all resource files.

To add a feature resource: (for install feature’s Display Name and Description)


To localize your English feature into German and Japanese, you add three Resource File project items to your project: Feature resource files cannot be used to localize ASPX markup or code; separate resource files are required for them.

After you create the feature resource files, add translated strings to them. Access the localized strings with an expression in the following format:

$Resources:String ID

The scope of feature resources is local to the feature they are added to. To create resources that can be used by any feature or element file in the solution, add a Global Resources File
project item instead of a feature resource File. The Global Resources File project item is located in the 2010 folder under SharePoint in the Add New Item dialog box. Global resources files deploy to the \Resources folder of the SharePoint root folder.

Localizing ASPX Page Markup

If you are localizing only markup and not code, add a Global Resources File
project item. If you are localizing code and markup, add a Resources File project item.

If only localize markup – then add Global Resource File (remember MG)

If markup and code, add Resource File

<asp:Button ID=”btn1″ runat=”server” onclick=”btn1_Click” Text=”<%$Resources:Resource1,String7%>”></asp:Button>

Change the Deployment Type
property of each resource file to
AppGlobalResource to cause them to deploy to the server’s App_GlobalResources folder.

Code

Get the resource string in code:
HttpContext.GetGlobalResourceObject(“Resource File Name”, “String ID”)

In package designer, click Advanced, add each resource file.dll in the location.

———————————————————————————————

For a BDC solution – a resource is named *.bdcr

———————————————————————————————


 

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: