Override the neutral language of a specific resource file within an assembly
I have an assembly that contains several resource files. Most of them have the neutral language 'nl' (Dutch, specified on the assembly as the neutral language), so I don't specify the 'nl' in their filenames.
However, I'm putting strings in the English language in some other resource files (they are internal error messages) and I will never provide Dutch translations of them.
If I name those resource files something like 'Errors.en.resx', no designer class is generated (breaks the build) because there is no 'Errors.resx'. This is annoying because now I have to put 'en' strings into a 'nl'-implied resource file and I really don't want to translate those strings to 'nl' or provide empty strings just to sati开发者_开发技巧sfy the compiler.
Is there a way to override the neutral language on a specific resource file or perhaps somehow have the 'Errors.en.resx' build a designer class?
If the strings are not to be translated, consider the use of constants in a static class if they are not referenced by other assemblies.
If the strings are reused across several assemblies consider specifying them as static readonly
since this will allow for the other assemblies to load a new version of the strings without the need to rebuild them. For this scenario you can even go one step further and specify a public static property with only the get
accessor which in turns uses the private static readonly
field.
精彩评论