Professional Documents
Culture Documents
Windows Store UI Localization
Windows Store UI Localization
Windows Store UI Localization
Session - 2
Localization is the concept of translating the content to a specific language by means of multi-
lingual support. Visual Studio Integrated Development Environment (IDE) is built-in such a way
that it can be used to develop applications for various countries with their local language
support.
In Windows Store apps, Visual Studio has introduced a new localization technique called Hub
and Spoke. The hub and spoke model is designed to provide a home screen for the app to which
all other screens will navigate in a linear manner.
Hub:
CultureInfo.CurrentCulture is the property that is used to set the culture of an app to current
culture. Before checking an app for localization, the developer must develop an app and change the
language through the Control Panel to test for localization.
To set the language:
Open Control Panel, click Language and Region, and navigate to Language.
For packing and deployment, the .NET Framework uses the Hub and Spoke model. The main
assembly for the app is the Hub, which holds the code to be executed. The satellite assembly is
connected through spokes and hence, coding is not required.
Note - For each app, implementing localization creates a new assembly namely, Hub,
which has the local language specifications.
Generally, to globalize an application, there is no need for any code for its cultural settings, but in
case of Localization, cultural settings must have their own code and images to translate the app.
Following figure shows an example of how localization occurs:
String Data
When a user develops a store app, it may contain more text than images. If the app is required
to localize the text in the app, the text must be placed inside the associated resource files. These
resource files should be created in the directory named as strings and identified through an
extension .resw. Each language must be created under its own language folder, under the
respective strings folder.
Images
Localizing images is easier than localizing the text. A folder named images is created and then, all
the images are stored in this folder and the same name is given to the image files kept in the
different language folders. Following Figure shows how to create the folders and the image files:
The user can send these values in string format to any constructors. The user must make
sure to avoid the formats that are not available in all languages.
The users can use the following formats while developing their app:
Code
Snippet:
var c = Windows.System.UserProfile.GlobalizationPreferences.Currencies[0];
var cf = new Windows.Globalization.NumberFormatting.CurrencyFormatter(c);
var cn = 1;
var cfd = cf.Format(currencyNumber);
var cp = cf.ParseDouble(cfd);
When working with the formatters, set the IsGrouped and FractionDigits properties.
These properties will decide whether to display the group separator and minimum number of
fractional digits to be displayed.
Before sharing the app to Windows market, the user must localize the manifest which is
used to view the translated content of the app in the Windows Store.
After installing the Toolkit, the following steps must be performed for enabling Multilingual
Toolkit.
Launch Visual Studio 2013.
Enable Multilingual option by navigating to Tools Enable Multilingual App Toolkit
option as shown in the following figure. This creates the resource files languages required
and also for a pseudo language. The pseudo language is needed for testing Store apps to
ensure that text is used from inside the resource files.
The user can create a multi-lingual app by creating a resource file which has an extension
.resw and integrate that into the app. These files can be called through a simple reference
in the code. The resource file design is shown in figure.
Code
Snippet:
<Page
x:Class=”LanguageLocalization.MainPage”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
xmlns:local=”using:LanguageLocalization”
xmlns:d=”http://schemas.microsoft.com/expression/blend/2008”
xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006”
mc:Ignorable=”d”>
<Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”>
<ComboBox Margin=”538,155,0,0” SelectedIndex=”0” SelectedValuePath=”Name”
x:Name=”ddlLang” Grid.Column=”0” HorizontalAlignment=”Left”
When the application is executed, the When the user clicks the Get Value
output will appear as shown in the button, it reads the resource file and
following figure: displays the result as shown in the
following figure.:
The user can make use of CharacterGroupings class which is available inside the namespace
Windows.Globalization.Collation for ordering the group or collation of a language.
Code
Snippet:
using System;
using Windows.Foundation.Metadata;
namespace Windows.Globalization.Collation
{
[DualApiPartition(version = 100794368u),
MarshalingBehavior(MarshalingType.Agile), Version(100794368u)]
public sealed class CharacterGrouping : ICharacterGrouping
{
public extern string string1
{
get;
}
public extern string string2
{
get;
}
}}
Code Snippet
(Cont):
When en-US is used for localization, the user receives special char groupings
such as &, ;, ‘, or 0-9 and all alphabets.
Note - The user can employ the method Lookup to receive the string of a label.
Through the DateTime type, Windows Store apps can be made culture-sensitive. Based on
the culture, the DateTimeFormatInfo class is called to format the Date.
When the user needs to format a date through ShortDatePattern format, the date
March 1, 2014 can be formatted as 3/1/2014 for the English (United States) ’en-US’ culture,
and 01/03/2014 for the English (United Kingdom) ’en-GB’ culture. The object for
DateTimeFormatInfo can be formed for a specific culture.
In the following Code Snippet, a date object is created which shows current system date.
Code
Snippet:
using System;
using System.Globalization;
using System.Threading;
public class GetDateFormat
{
public static void Main()
{
DateTime d = DateTime.Now;
Thread.CurrentThread.CurrentCulture = new CultureInfo(“en-US”);
Console.WriteLine(d.ToString(“d”));
CultureInfo c = new CultureInfo(“de-DE”);
Console.WriteLine(d.ToString(“d”, c));
}
}
Generally, there is no need of writing lines of code for globalizing an app for its cultural
settings, but in case of localization, its cultural settings must have its own code and
images to translate the app.
The user must check the languages to be declared in the app inside the Manifest file.
Windows Store will list all the languages that can be localized.
The user can create a multilingual app by creating a resource file which has an
extension .resw and integrate that into the app.
In the DateTime type, use the Store app to make culture-sensitive procedures. Based on
the culture, the DateTimeFormatInfo class is called to format the date.