Localization is the process of enabling an application for particular country, region or group by adding local specific component and by translating strings displayed in UI to local language. Localizing application expands the reach of application to more number of people and group. For each local or culture you wish to target, you will need separate set of resources that match that specific local or culture. The culture is presented by string that has language and region denoted. Like French includes below. In this article we have seen step by step implementation of localization in Silverlight. Please download attached sample application to see actual implementation.
There are few things your application should be able to adopt:
fr-BE French - Belgium
fr-CA French - Canada
fr-FR French - France
fr-LU French - Luxembourg
fr-MC French - Monaco
fr-CH French - Switzerland
Above is small description about localization, next we will see step by step approach to implement Localization in Silverlight. I am going to use English and Hindi resources as an example for this article.
Create Silverlight Application.
To add resource file right click on Silverlight project, select Add > New Item. 
In Add New Item dialog box select "Resource File" template, give resource name "Resource.resx" and click on Add button.
To add resource string in resource file, open resource file and type "CountryName" in Name column, "India" in value column and "Name of my country" in comments column. And set "Access Modifier" to public.
Add another resource file for Hindi based resources. Give the resource file name "Resource.hi-IN.resx". Note that the resource file name should be in "Resource.<local>.resx" format. Add resource string like we did in step #3. 
Register resource in MainPage.xaml to use localized resource string as static resource.
<Grid.Resources>
<local:Resource x:Key="ResourceString"></local:Resource>
</Grid.Resources>
Bind resource key in TextBlock to display localized string in UI.
<StackPanel HorizontalAlignment="Center" Margin="10,10,10,10">
<TextBlock Text="{Binding CountryName, Source={StaticResource ResourceString}}"/>
</StackPanel>
At this point if you run this application you will get XamlParse exception.
The above exception is thrown due to a known issue of access modifier in resource class constructor. We did set the Access Modifier to "Public" but the resource class constructor is still "internal". To change this to "public", open Resource.Designer.cs and modify the constructor access modifier to "public". Every time you open resource designer and make some change, you have to again modify it to "public".
public Resource()
You may create resource wrapper class to avoid modifying constructor access modifier again and again.
To switch application between English and Hindi, you have to specify supported culture in Silverlight project file. In order to do this you have to unload Silverlight project from solution. Right click on Silverlight project and select "Unload Project". Again right click on the same project and select Edit project. Add below line of code inside "PropertyGroup" element.
<SupportedCultures>en-US;hi-IN</SupportedCultures>
Right click again on the Silverlight project and select "Reload Project".
To specify target local in your aspx page, open the aspx file and add below line of code inside Silverlight object.
<param name="uiculture" value="en-US"/>
Run the application, you will see below in output.
Now change uiculture to "hi-IN" and run the application again. You can see output where the country name is displayed in Hindi.
<param name="uiculture" value="hi-IN"/>![]()
Localization in Silverlight 4.0
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh DodiaPosted Mar 18, 2015, 8:33 AM
how can we change the culture dynamically? (<param name="uiculture" value="en-US"/>)
vishnu vardhanPosted Dec 13, 2011, 11:56 PM
Hi, with out creating resource file or storing in to the dB and fetch the db based on selecting the lang. I want to get localize by dynamicali. becuse i can not store all the words which are having in diff lang. So is der any componet for taking care of localizaion. If it's der please let me know. My mail id :[email protected]
Balamurugan RanganathanPosted Jan 12, 2011, 1:56 AM
Task could not find "AL.exe" using the SdkToolsPath "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\" or the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A". Make sure the SdkToolsPath is set and the tool exists in the correct processor specific location under the SdkToolsPath and that the Microsoft Windows SDK is installed I got this error please help me out
KonstantinPosted Oct 27, 2010, 4:23 PM
There is free VS addin http://wpflocalizeaddin.codeplex.com/ that helps extracting strings into resources.
olive olivePosted Sep 17, 2010, 8:53 AM
You save my Day.Ask your boss for a raise of your salary :)
ShivprasadPosted Jul 19, 2010, 3:42 AM
Very good work pradeep. That public constructor saved my day. Shivprasad koirala