23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

User Language and Other Settings<br />

When a user first acquires a Windows 8 device or installs Windows 8 on a machine, it will likely be<br />

configured for their country of residence. However, many users speak multiple languages irrespective of<br />

where they live and might want to work with Windows in a particular language that has nothing to do<br />

with their location. For this reason, you always want to think about the user’s preferences separately<br />

from the actual location of the device, applying the user’s preferences to how your app displays<br />

information but using the physical location to control the services you use and other more functional<br />

aspects.<br />

Languages and other preferences are configured through Control Panel > Clock, Language, and<br />

Region. Here you can add languages and select your primary one (see Figure 17-8), change input<br />

methods, specifically set your location (a country or territory), and set date, time, number, and currency<br />

formats (see Figure 17-9).<br />

FIGURE 17-8 Managing and selecting a language in Control Panel.<br />

It’s a good thing there are globalization APIs, because dealing with all the variations here would be<br />

quite a chore otherwise! (Note that changes to the formats in Figure 17-9 will affect only those<br />

Windows Store apps that are running in the language you’re configuring; each set of custom formats is<br />

particular to a language.)<br />

The basic details of the user’s settings are available through the<br />

Windows.System.UserProfile.-GlobalizationPreferences object and the classes in the<br />

Windows.Globalization namespace. GlobalizationPreferences just provides a handful of properties.<br />

Four of these, calendars, clocks, currencies, and languages are each an array of strings (an<br />

IVectorView to be precise) with the user’s preferred settings in order of preference. In the case of<br />

languages, it contains a list of BCP-47 language tags.<br />

798

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!