开发者

Are there any guidelines on how to organize non-string resources for localization for .net apps?

Assume

My.dll 
- Resources
  - MyResources.resx
    embeds MyFile.ext with key MyFile
  - MyResources.de.resx
    should embed MyFile.de.ext with key MyFile

I've tried using search eng开发者_StackOverflow社区ines but to no avail.

I find that unless both resx files are in the same folder, the whole culture switching mechanism doesn't work for some reason. So that killed my idea to have a subfolder called de containing the resX and all linked resources.

My.dll
- Resources
  - MyResources.resx
  - MyResources.de.resx
  - en-US
    - all en-US non-string resources
  - de
    - all de non-string resources

For the de version, I copy-paste the neutral (en-US) version. I then have to manually delete the en-US [Res], add de [Res] and then rename for each non-string resource (e.g. images,csv or other files)

Is this how it is supposed to be done ?


I find that unless both resx files are in the same folder, the whole culture switching mechanism doesn't work for some reason. So that killed my idea to have a subfolder called de containing the resX and all linked resources.

That's correct. That's because when you move the .RESX file into other folder VS auto-generates namespace name for .resx`s generated class as full path to the .RESX file. I.e. if LocResources.resx is in $PROJECT$\MyResources\de\ folder then the auto-generated class full type name would be $PROJECT_BASE_NAMESPACE$.MyResources.de.LocResources.

The key 1 here is that embedded resource name for every .RESX will be equal its code-behind type full name + '.resources'.

The key 2 here is that using localization based on satellite assemblies (default), ResourceManager loads resources by its (static) full name but from different satellite assemblies for every language.

So if you move xxx.de.resx out of folder where all .RESX are stored, namespace (and embedded resource name) for this resource will be changed and ResourceManager won`t find it in the satellite assembly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜