stevencohn / ResxTranslator

Automates the translation of resx files using throttled access to the Google Translation API
MIT License
20 stars 5 forks source link
csharp resx translate

ResxTranslator

Translates entire resx files or individual bits of text to multiple languages.

There are four main tabs

Inspired by https://github.com/salarcode/AutoResxTranslator

Translate Resx File

Translates an entire .resx file to one or more languages.

  1. Choose a .resx file to translate. It will detect the language based on the language/culture code in the filename, or English if no code is included. It will remember the last file translated.
  2. Choose the output directory where new .resx files should be stored. If this is left blank then new files are stored in the same directory as the source file.
  3. Choose the target translation languages.

Options

Language Selections

Translate Resx

Working

Translate Resx

Skipping Resources

If the resource file includes control or configuration entries that should not be translated then flag these by including the word !SKIP in the entry's comment. It must be capitalized. The comment can include other text besides the word !SKIP.

Using an Override Hint File

While Google translator is generally quite good, there are nuances in languages that it can't predict and may make a native speaker question the appropriateness of the translation. For each language, you can provide an optional hint file that contains preferred translations for each resource identifier. This must be an XML file located in the same directory as the source resx file and must be named name.code-hints.xml, for example Resources.de-DE-hints.xml.

The contents of the hints file should look similar to the following:

<?xml version="1.0" encoding="utf-8"?>
<hints>
  <hint name="resouce-identifier1">
    <source>
      copy of the source text from the main resx file
    </source>
    <preferred>
      my preferred translation here
    </preferred>
  </hint>
  <hint name="resouce-identifier2">
    <source>
      copy of the source text from the main resx file
    </source>
    <preferred>
      my preferred translation here
    </preferred>
  </hint>
</hints>

When resources are translated to that language, ResxTranslator will first look in this hint file each resource identifier and use the available text before attempting to use Google translate.

Notice that the file includes a copy of the original source text. ResxTranslator uses this to detect if the source item has been updated since this hint was last created and display a warning that the hint may be out of date and needs correcting.

Translate Text

Translate one string, phrase, or paragraph of text.

Translate Text

Inflation Detection

The free Google translator will sometime add extra spaces around non-alphanumeric characters when translating. For example "x+1" may become "x + 1" (from no spaces around the plus sign, to spaces around the plus sign.) x

ResxTranslator attempts to detect this string inflation and displays a warning for each string that may need manual tuning. Of course, the program itself has no way of knowing the exact context of the translation so it simply compares the number of spaces in the input string and the output string. Most of the time, the translation is accurate and shouldn't need to be adjusted manually.

Analyze

The Analyze tab analyzes a resx file looking for duplicate uses of words and phrase.

Analyze Resources

Ignoring Known Duplicate

There will likely be legitimate cases where you want to use duplicates but in very different contexts. In these case, you can tag those resources with the !NODUP keyword; the analyzer will ignore those resources and not report them as duplicates.

Tools

The Tools tab contains operations that help maintain resx files.

Translate Text

Sort Data Items

Sorts the <data> items within a resx file alphabetically by resourceID. This makes it easier to find specific resources when viewing the file in a text editor.

Update Hint Sources

Updates the values of the <source> elements within an override hints file. This should be used when the original source text has changed so you can verify individual items. It can also be used to fill in any missing <source> elements or values or correct the case-sensitive resource name of each hint.