WPF globalization and localization, and WPF globalization Localization

Source: Internet
Author: User

WPF globalization and localization, and WPF globalization Localization

When an App needs to launch a multi-language version, it needs to use the [Globalization and localization] service.

PrincipleAndProcess

The resource file contains all the control information. By exporting the control information, you can modify the string of its corresponding attributes (such as the Text attribute of TextBlock) to implement a multi-language version. In the resource file, the control is marked by x: uid.

 

To internationalize WPF, follow these steps:

1. in *. add the language/localization information to the csproj. After the project is regenerated, the en-US directory is displayed under the bin directory, which contains the en-US localized resource information *. resources. dll.

Add <UICulture> en-US </UICulture> under <PropertyGroup> in the * p. csproj file.

Enable [assembly: NeutralResourcesLanguage ("en-US", UltimateResourceFallbackLocation. Satellite)] In AssemblyInfo. cs.

Regenerate the project.

2. Add and check the uid.

Automatically add UID msbuild/t: updateuid HelloApp. csproj to XAML

To verify that you do not have a missing or duplicate UID, runCheckuid: Msbuild/t: checkuid HelloApp. csproj

3. Extract, modify, and re-generate the source file (dll)

Tool: You can use Microsoft's non-production tool LocBaml.exe or other visualization tools. For example, Visual LocBaml.

Extraction: LocBaml.exe/parse en-US/HelloApp. resources. dll/out: Hello.csv

Generate: LocBaml.exe/generate en-US/HelloApp. resources. dll/trans: Hello.csv/out:. \/cul: zh-CN

4. Change the program run to cultrue.

Modify the Operating System Language/region.

You can also set parameters in the dynamic setting area of the App. (You need to restart the App)

Var lan = HelloApp. Properties. Settings. Default ["Language"] as string;
Var cultrue = new CultureInfo (lan );
CurrentThread. CurrentCulture = cultrue;
CurrentThread. CurrentUICulture = cultrue;

 

 

There are several other ways to dynamically change the language environment, but the above methods have the following advantages:

  • The source program does not need to care about multiple languages. For example, the dynamic binding Based on. xaml, the dynamic binding of XMAL or the resource (k, v) all restrict the language types that can be translated at the development level.
  • Translation can be performed after the program is developed.
  • After the UI is determined, it can be outsourced to the translation team for parallel operations.

 

And ....

 This is just a simple text translation. It also includes usage habits, formatting features, and many other interesting content.

 

 

Refer:

 

How to: localize applications, https://msdn.microsoft.com/zh-cn/library/ms746621.aspx

 

 

  

 

 

Related Article

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.