Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Losing localisation of dynamically loaded assemblies
2 replies. Latest Post by GuinnessKMF on December 23, 2008.
(0)
Jargon64
Member
4 points
7 Posts
12-12-2008 7:38 AM |
Exactly what the subject says...
I've got a Silverlight project that retrieves more assemblies from the web server and loads them at run-time when needed. After looking around the web for a while I found a few articles/posts saying how Silverlight localisation is kind of broken so you need to implement a couple of workarounds that I have done and its working well now... but only for the main project.
The problem occurs in any control created out of one of the dynamically loaded assemblies, it's as if it is not inheriting the locale/culture correctly. When testing, the dynamically loaded assemblies drop back to the default locale resource file (LocStrings.resx), but only if the attribute value is accessed through a XAML binding. If I test what culture is currently active using code-behind it seems to report it correctly (e.g. en-US, en-GB, etc), so I'm really not sure how to get the XAML binding to access the correct resource file.
I used ASP code-behind to detect the user's locale and pass it to the Silverlight app as an InitParam and access this from inside the Silverlight app. During the start-up of the Silverlight app I manually set the CurrentCulture and CurrentUICulture to the passed parameter. This fixed the localisation for the main project for both the code-behind and XAML bindings (was accessing the correct resources files). But like I said above, any controls created from the dynamically loaded assemblies seem to test correctly when checking their current culture but it does access the correct resource files and just defaults to the fallback with the XAML bindings.
Anyone encountered this problem before?
slyi
Participant
818 points
251 Posts
12-23-2008 1:27 PM |
I dont exactly what is going wrong based on your explaination so far, but are you exposing the Usercontrols loc UI strings in the main application as your application initializes your controls eg: http://wpf-e.spaces.live.com/blog/cns!2B248D261D0E0035!314.entry
Another thing that may cause this, if your dynamic assemblies are part of a seperate SL project that does not contain full list SupportedCultures in your csproj.
GuinnessKMF
222 points
58 Posts
12-23-2008 1:56 PM |
Do your bindings implement INotifyChanged? If it loads the default culture and binds that culture, and then you set the culture but do not raise a notify property changed event, then the bindings won't update.