Search code examples
.netglobalization

Word Count of .resx files


we will be processing our .resx files for translation. Since these files have lots of xml data apart from strings to be translated, I was looking for a way where we can count the words/strings that are translated. We have winform created resx file

Thanks.


Solution

  • Look for properties named Text and other properties that represent the translatable strings you care about.

    System.Resources.ResXResourceReader reader = new System.Resources.ResXResourceReader(@"..\..\Form1.resx");
    foreach(System.Collections.DictionaryEntry de in reader)
    {
       if (((string)de.Key).EndsWith(".Text"))
       {
          System.Diagnostics.Debug.WriteLine(string.Format("{0}: {1}", de.Key, de.Value));
       }
    }