[Silverlight getting started series] multi-language and resource usage of modules/modules in Prism

Source: Internet
Author: User

The previous article explains how to implement internationalization/multi-language in Silverlight. Here we will introduce how to implement multiple languages and use resources in modules/modules in prism.

The implementation of multiple languages is the same: Add strings. resx, strings. en-US.resx, strings. zh-CN.resx and so on, then modify the first constructor to public, manually modify the project file, add cultures, and then add a resource file such as styles. in XAML, put your template, style, strings, and other resources.

The same is true in view with multiple languages.

 
1: xmlns: res = "CLR-namespace: mynamespace. Resources"
 
2:<Usercontrol. Resources>
3:<Res:Strings X:Name="Mytextstrings"></Res:Textstrings>
 
4:</Usercontrol. Resources>
 5:    grid   x :  name  = " layoutroot "  background  = " white "  height  = " 25 "  width  = " 125 " > 
6:<Textblock Height="25" Horizontalalignment="Left" Name="Textblock1" Text="{Binding navigateentry, source = {staticresource mytextstrings }}" Verticalalignment="TOP" Width="121" />
 
7:</Grid>

At the application level, multiple languages automatically use the resource files corresponding to the current language based on the current thread's culture.

The key is that other resources need to be registered.(Modify the relative path of your XAML resource file as needed)

 
1: [moduleexport (Typeof(Mymodule), initializationmode = initializationmode. OnDemand)]
 
2:Public ClassMymodule: imodule
 
3 :{
 
4:
 
5: # region imodule members
 
6:
 
7:/// <Summary>
 
8:/// Notifies the module that it has be initialized.
 
9:/// </Summary>
 
10:Public VoidInitialize ()
 
11 :{
12:// Register resources
 
13: var Assembly = assembly. getcallingassembly ();
 
14: URI uri =NewUri ("/"+ GetType (). Assembly. tostring (). Split (',') [0] +"; Component/resources/styles. XAML", Urikind. Relative );
 
15: application. Current. Resources. mergeddictionaries
 
16:. Add (NewResourcedictionary
 
17 :{
 
18: Source = URI
 
19 :});
 
20 :}
 
21: # endregion
 
22 :}

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.