Programmatically find if an alternative translation exists or not in a .resx file

I have a project that has translations in multiple .resx files.

eg.

  • Admin.resx
  • Admin.fr.resx
  • Admin.it.resx
  • Admin.de.resx

Does anyone know how you can programmatically find out if a translation exists in an alternative language file that exists in the default backup mode?

Hope this makes sense!

+4
source share
1 answer

This should do what you want.

public static bool StringExistsInCulture(string key, CultureInfo ci) { ResourceManager resources = new ResourceManager(typeof(Admin)); string defaultString = resources.GetString(key, CultureInfo.InvariantCulture); string transString = resources.GetString(key, ci); return (defaultString == transString); } 
+3
source

All Articles