How can I stop the ResourceManager from default to the current culture if the key is not found

The question is pretty clear, but here's an example of playback.

I have three resx files:

Translations.resx Has code generation enabled and no key-value pairs 

 Translations.en.resx String1 : Value1 String2 : Value2 

 Translations.fr.resx String1 : Valeur1 

To get a resource from a French resource, I can call:

 Translations.ResourceManager.GetString("String1", new CultureInfo("fr")); 

Returns Valeur1 as expected. Changing the parameter to String2 returns Value2 , which follows the backup resource .

What I would like to do is disable this process and allow null return if the key is not specified in the specific culture that I provided GetKey . Is it possible, and if so, how to do it?

+4
source share

Source: https://habr.com/ru/post/1480003/


All Articles