Question

Sorry, in advance for my English, its my first post here. I've got strange problem with RESX, supported culture in Silverlight. Its silverlight app with 1 web(asp.net) project which start whole silverlight app, 1 main project(silverlight, sl.Application) and others which are use as modules(silverlight) in main project (solution explorer screen: http://i.imgur.com/A4sHWRI.png?1 ). Sl.Application can invoke other projects and use theirs views as part of the main view placed in sl.application

I tried to add different cultures, so:

I add to my app Supported cultures EN and CS to each cs.proj.

<SupportedCultures>pl;en;cs;de;ru;cz;sk</SupportedCultures>

My Neutral culture is set to PL in assemby info in each project.

[assembly: NeutralResourcesLanguageAttribute("pl-PL")]

Create resx Files for different cultures, here fol PL, EN , CS: http://i.imgur.com/P6woiV2.png

At starting app you can choose which culture you want, by clicking on specific flag. First lets start with PL - its neutral culture, so i dont have to change anything. Using

var culture = System.Threading.Thread.CurrentThread.CurrentUICulture;

var test_en = Resources.DrivesBook.ResourceManager.GetString("AdresArrival", culture);

I checked that culture is set to PL and resource (DriveBook.resx) return correct string in PL

Next: Let's try EN, Start App, choose EN flag - change culture to en-GB.

System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-GB");

Using same code as above, returns me EN string so its still good

The best begins when i tried to use CS. Same as above, I choose CS flag - change culture to cs-CZ Using in SL.Application

var culture = System.Threading.Thread.CurrentThread.CurrentUICulture;

its returns me cs-CZ culture so I thought that there will be ok, when I call

var test_cs = Resources.DrivesBook.ResourceManager.GetString("AdresArrival", culture);

it returns me string from CS culture, still all works fine, so where is the problem?

When i tried same in others projects (from Common or Modules folder), here comes magic :)

Same as above Using in Modules.Auxiliary

var culture = System.Threading.Thread.CurrentThread.CurrentUICulture;

still OK, we got cs-CZ culture, seems to works fine, but

var test_cs = Resources.DrivesBook.ResourceManager.GetString("AdresArrival", culture);

it returns me string from PL culture, not from CS

Summation: Changing culture works fine, for EN, whole app got EN string from resx files, but when I change to CS, only SL.Application can resolve *.cs.resx file, other projects looks like they have not seen *.cs.resx files. While adding En and CS I d exactly same work for both and EN work fine, but CS not. its there any posibily that there is some property in cs.proj that limit max supported cultures in current project, or do you have any idea what I did wrong?

Was it helpful?

Solution

ok, I solved it by myself Problem was in my custom framework, which was responsible for differential loading resources. Resolving dll only via filename, not included filePath (here folder cs, en for different cultures) caused overwrite files depending on the lexical order, so CS.resx was loaded firstly, but later I load EN resource and overwrite cs.resx. This framework starts working when comes to loading main xap. Main sl project works, cuz it was loaded earlier, e.g. for loading screen so resource.cs.resx was loaded when my framework couldn't corrupt it

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top