0

I have a single resource file (.resx) that defines the following languages:

  1. neutral - International English as the default/fallback language
  2. en-US - Sparsely populated for words like colour/color
  3. de - German translations

To get a resource string I am using the 'System.Resources.ResourceManager(Type resourceSource)` as follows:

var culture = new CultureInfo("en");
var resourceManager = new ResourceManager(resourceType);
var translatedString = rm.GetString("FavouriteColour", culture)

When I call the above with the culture set to en-GB I get the default/neutral resource value of "Favourite Colour" as expected, but if I specify the culture as simply en I get the en-US resource value of "Favourite Color"

Why does the ResourceManager resolve the neutral en language to the en-US variant and is there any way to stop this behaviour?

Neilski
  • 4,385
  • 5
  • 41
  • 74
  • The [Resource Fallback Process](https://msdn.microsoft.com/en-us/library/sb6a8618(v=vs.100).aspx#Anchor_1) explains what is happening. And what do you mean by "stop this behavior"? Do you mean you don't want a resource resolved at all if there is not an exact culture match? – Crowcoder Aug 18 '16 at 12:25
  • "Stop this" was badly phrased, but I had expected that if I asked explicitly for the neutral version of the language, in the case 'en' then I would have either received that that version, if defined, or it would have fallen back to the default/neutral definition in the resource. I did not expect 'en' to translate to 'en-US'. – Neilski Aug 18 '16 at 12:59

0 Answers0