Intersoft ClientUI Documentation
Walkthrough: Create a Localizable Silverlight Project

This walkthrough shows you how to create a new project using avaiable Intersoft ClientUI Silverlight project template, configure the project to enable multiple cultures, and add resource files that you can consume in Silverlight XAML pages.

In this walkthrough, you perform the following tasks:

Prerequisites

You need the following components to complete this walkthrough:

Creating a Silverlight Intersoft ClientUI Project

This section describes how to create new Intersoft ClientUI project in Visual Studio using the available Intersoft ClientUI project template. This walkthrough is using Visual C# template. However, ClientUI also provides the project templates in Visual Basic.

To create a Silverlight Intersoft ClientUI project

  1. Start Visual Studio 2010.
  2. On the File menu, click New and then Project.
  3. The New Project dialog box appears.
  4. In the Installed Templates pane, expand the Visual C# node and select Silverlight.
     
  5. Select the ClientUI template you wish to use in your project.
  6. Specify a Name and a Location for the application and then click OK.

Configuring Silverlight Project for Multiple Cultures

Silverlight project, by default, supports only neutral culture in Visual Studio 2010. Since Visual Studio has not supported the user interface to enable multiple cultures in a Silverlight project, you need to edit the project file manually outside Visual Studio such as explained in the following walkthrough.

To configure Silverlight project file manually

  1. Close the Silverlight project and optionally exit Visual Studio.
  2. Open Windows Explorer and locate the ClientUIApplication1.csproj in the folder where it was previously created.
  3. Edit the ClientUIApplication1.csproj using a text editing application such as Notepad.
  4. Add SupportedCultures node under the PropertyGroup node and specify the desired cultures as the value of the node, such as shown in the following code.

    ClientUIApplication1.csproj
    Copy Code
    <SupportedCultures>fr,de,es</SupportedCultures>

    The results look like the following illustration.

  5. Save the changes.
  6. Start Visual Studio and open the Silverlight project.
To learn more about the culture format, resource concept and the localization best practice, see the Silverlight Localization topic in MSDN Library.

Adding Localized Resource Files

The final step is to add the resource file to your Silverlight project which contains the strings that you would like to localize. This walkthrough shows how to add the default resource file with code generation, then followed with the resource files for other cultures.

To add a default resources file

  1. Create a new folder named Localization in the root folder of your Silverlight project.
  2. Right click on the newly created folder and choose the New Item command from the Add menu in the context menu.
  3. Locate and select the Resources File from the Installed Templates list such as shown in the following illustration:


  4. Name it Resources.resx for the default resources file.
  5. Open the Resources.resx file in Visual Studio.
  6. Change the Access Modifer option to Public (the default is Internal). This step is required to allow data binding to the resource entries. See the following illustration.


  7. You can now add the strings that you would like to localize. For example, add a string with the name set to TodayText and the value set to today.

To add additional resources file for other cultures

  1. In the Localization folder, add a new Resources file similar to the steps in the previous section.
  2. To add a new resources file for France culture, you add the .fr after the file name which indicate the culture for the France resource, for instance, Resources.fr.resx. Silverlight automatically recognizes the resources file for the culture at compile time.
  3. Make sure that Access Modifier option is set to No Code Generation.
  4. Add the strings that you would like to localize. The name of the string should be consistent with the name you used in default resource, for instance, to localize the TodayText in France culture, you add a new entry for TodayText and set its value to aujourd'hui. See the following illustration.


  5. Repeat the above steps to add resources for other cultures as you desire.
See Also

Other Resources