Windows 8 Store Apps Learning (57) Localization and globalization

Source: Internet
Author: User
Tags resource xmlns

Introduced

Re-visualize the localization and globalization of Windows 8 Store Apps

Localization-Demo

Localization-changing languages

Globalization-Demo

Globalization-Formatting numbers

Example

1. Demonstrate the basic application of localization

Localization/localizationdemo.xaml

<page x:class= "XamlDemo.Localization.LocalizationDemo" xmlns= "HTTP://SCHEMAS.MICROSOFT.COM/WINFX/2006/XAML/PR Esentation "xmlns:x=" Http://schemas.microsoft.com/winfx/2006/xaml "xmlns:local=" using:XamlDemo.Localization "x" Mlns:d= "http://schemas.microsoft.com/expression/blend/2008" xmlns:mc= "http://schemas.openxmlformats.org/ markup-compatibility/2006 "mc:ignorable=" D "> <grid background=" Transparent "> <stackpanel margin= "0 0 0" > <textblock fontsize= "14.667" > <Run> localized resource file , the following examples illustrate:</run> <linebreak/> <run>1, in the En directory is the English resource file, in the ZH-CN directory is Simplified Chinese (z  H stands for language, CN for country or region) resource file </Run> <linebreak/> <run>2, RESOURCES.LANG-EN.RESW representative of English resource files, RESOURCES.LANG-ZH-CN.RESW representative of Simplified Chinese resource files </Run> <linebreak/> <Run> 3, the image resources localization may refer to the above naming rule, simultaneously may with scale and highContrast combined </Run> <linebreak/> <run>4, the strings referenced in Package.appxmanifest also support this
                localization, citation: Ms-resource:hello or ms-resource:///resources/hello</run> <linebreak/>
                The strings referenced in <run>5, Tile, and Toast also support localization, referencing: Ms-resource:hello or ms-resource:///resources/hello</run> 
            <linebreak/> <run>6, when the resource for a language cannot be found, the system automatically uses the resource corresponding to the default language set in Package.appxmanifest </Run> </TextBlock> <!--to localize the properties of the control by X:uid, refer to Hellotextblock.font in the resource file
    
            Size and Hellotextblock.text--> <textblock x:uid= "hellotextblock" margin= "0 0 0"/>  <!--Code-behind ways to get localized resources--> <textblock x:name= "Lblmsg"
            Fontsize= "14.667" margin= "0 0 0"/> <!--localization of images--> <image source= "/localIzation/logo.png "width=" height= "margin=" 0 0 0 "horizontalalignment=" left "/> & Lt;/stackpanel> </Grid> </Page>

Localization/localizationdemo.xaml.cs

* * Demo BASIC application of localization * * Another: * Visual Studio 2012 Multilingual Application Toolkit See: http://msdn.microsoft.com/zh-cn/windows/apps/hh848309
* * using Windows.ApplicationModel.Resources;
Using Windows.ApplicationModel.Resources.Core;
Using Windows.UI.Xaml.Controls;
    
Using Windows.UI.Xaml.Navigation; Namespace Xamldemo.localization {public sealed partial class Localizationdemo:page {public localizatio Ndemo () {this. 
        InitializeComponent (); } protected override void Onnavigatedto (NavigationEventArgs e) {/* * Resour Celoader Resourceloader = new Resourceloader (); -Get the default Resourceloader (resources in RESOURCES.RESW) * Resourceloader resourceloader = new Resourceloader ("MyResources "); -Gets the specified Resourceloader (resources in MYRESOURCES.RESW) * Resourceloader resourceloader = new Resourceloader ("Classlibr Ary/myresources "); -Gets the specified resourceloader of the specified class library (resources in the MYRESOURCES.RESW in the ClassLibrary class library) */
    
            Gets the default Resourceloader (that is, resources in RESOURCES.RESW) Resourceloader Resourceloader = new Resourcel
    
            Oader ();
        Gets the specified resource Lblmsg.text = resourceloader.getstring ("Hello") through the resource identifier; }
    }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.