Reputation: 140843
I have .resx file created for english (MyResourcesFile1.resx) and french (MyResourcesFile1.fr.resx). Both have the Access Modifier
to Public and they are both Embedded Resource
.
In the app.xaml.cs the even Application_Startup contain :
var languageInfo = new CultureInfo("fr");
Thread.CurrentThread.CurrentCulture = languageInfo;
Thread.CurrentThread.CurrentUICulture = languageInfo;
In many place in the Silverlight code I use the generated property that Visual Studio has provide.
string myString = MyResourcesFile1.MyPropertyValue;
Unfortunately, it only takes the localized string from the english file. Why?
Upvotes: 0
Views: 454
Reputation: 35
One of the options is insted of settings culture in App.xaml.cs, you can set in it the object tag.
<object ...>
...
<param name="culture" value="de-de" />
<param name="uiculture" value="de-de" />
...
</object>
Upvotes: 0
Reputation: 140843
I make it works finally by reading a lot of Microsoft Documentation.
Visual Studio 2010 doesn't have (yet) a menu to add the supported language for Silverlight project. To have your application working with all your resources files, it needs to be modified. The first step is to open the project solution with NotePad. Once it's done, search for SupportedCultures. Inside the bracket you can add the desired language (no need to add the default one). So mine looks like that now:
<SupportedCultures>fr
</SupportedCultures>
Reload the project and compile. If you set the thread like I were doing in the Application Startup, the resource is correctly loaded and displayed. I think it cannot be dynamically changed but it wasn't necessary for me.
Upvotes: 1