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 :}