views:

389

answers:

1

I am trying to modify an existing WPF application for localization. One of my restrictions is that all resources (including the default en-US fallback resource) have to be satellite resources. None of them can be embedded in the main assembly.

Through some reading on codeplex, I found that all I need to do is make the following change in my AssemblyInfo.cs file.

[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]

When I do this, I get an exception on application startup saying:

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "XXX.YYY.ZZZ.g.en-US.resources" was correctly embedded or linked into assembly "XXX.YYY.ZZZ" at compile time, or that all the satellite assemblies required are loadable and fully signed.

If I switch back to putting the fallback resource (en-US) in the main assembly, everything works fine again. From what I've read, if you want to have the fallback resource as a satellite resource, you must have a specific resource for that locale (i.e. you must have a Resources.en-US.resx). Am I correct?

What seems fishy to me in the exception is the g (.g.en-US). Does that signify something? The g doesn't exist in any of my resource files?

Am I creating my resources correctly. I first create a generic Resources.resx file, put all my strings in it. Then, I simply copy/paste within Visual Studio and rename for each specific locale (ar, es-MX, etc.). Then, make the appropriate translations.

For now, I am just focusing on one projects resource files. Maybe it's getting hung up on a different project that doesn't have an en-US version of it's resource file?? If so, is there any way to get Visual Studio to tell me more about what it's really getting hung up on?

+1  A: 

In short, your understanding of the resource files and what needs built seems correct.

The .g is for the compiled XAML files and built for you automatically. Nothing special or magical going on here.

Normally the fallback resource is embedded in the main assembly. If you are not doing that, you must create a satellite resource assembly for every culture you are going to do, plus an en-US one.

Adam Sills
In trying to understand the satellite fallback approach, I created a new WPF application. I added "[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]" to AssemblyInfo.cs. This gave me as above, but I was expecting this since I didn't create the en-US version of the Resources.resx file. Once I created this file, I now get a "Cannot locate resource 'window1.xaml'" error. This confuses me since I wouldn't consider a form a resource. After switching the fallback location to MainAssembly, I don't get the error. Any more ideas?
bsh152s
Wait, I guess I should read. The comments in the Assembly info say to add <UICulture>en-US</UICulture> to the project file. It seems redundant but doing that fixed the "cannot locate resource window1.xaml" issue.
bsh152s