Step 3 of 3: Setting the Culture

Once you've created resource files for your application, you will need to set the supported cultures for your project and explicitly set the current culture of the project. To do so, complete the following steps:

1.   In the Solution Explorer, right-click the C1DataGridLocalization project and select Unload Project. Click Yes if Visual Studio asks you to save the project.

The project will appear grayed out and unavailable.

2.   Right-click the project again, and select the Edit C1DataGridLocalization.csproj option.

In the .csproj file, locate the <SupportedCultures></SupportedCultures> tags. Add "es" in between the tags, so they appear similar to the following:

<SupportedCultures>es</SupportedCultures>

3.   Save and close the .csproj file.

4.   In the Solution Explorer, right-click your project and choose Reload Project from the context menu.

The project will be reloaded and will now support the specified cultures.

5.   In the Solution Explorer, right-click the MainPage.xaml file and click View Code in the context menu to open the Code Editor.

6.   Add the following using statements to the top of the file:

      Visual Basic

      C#

7.   Add the following code to the MainPage constructor above the InitializeComponent() call to set the CurrentUICulture property:

      Visual Basic

      C#

It should now look similar to the following:

      Visual Basic

      C#

8.   Save and run your application.

9.   To observe some of the localized language strings, select the drop-down filter icon in the grid:

 

 

10.  Click the drop-down arrow in the filter box to view additional strings:

 

 What You've Accomplished

In this step you added the file's culture to the project's supported cultures and set that culture to be the current culture. In this tutorial you've learned how to localize an application. You created a resource file, set the project's supported culture, and explicitly set the current culture in code.


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.