3

I am trying to build a Translation Assistant which can read in other compiled C# application (.exe), and display the forms from the EXE, are displayed individually, along with a table next to it with english column which will show the current english words on display, and another column for the value, which a translator can enter. Once completed translations, the translator can export the translations a resx file, to add to a project and also as an excel file for record purposes.

I am new to C# and hence am not sure if my strucute is correct, i have designed in such that a dll is inserted into the .exe during compilator, and then using this dll, the translation application can extract the string. This works for most strings, but it is getting stuck where there are several string that can apear in the same textbox at different times [e.g. disconnected, connected etc]. I have tried searching everywhere, but I am not able to find information on how i will be able to pull out all strings from an application, and be able to identify which form they belong to, in order to create my application?

the other issue i am faced with is, actually displaying the translated strings, the application i am building would benifit greatly if it could display a example of how the translated strings would look, as translations in some languages could be excessivly long. but i have found that i am only able to read in the aspects of the compiled applications and create an instance, but am not able to translate it.

I am reading in the exe using Reflection, and have understood from online that i need to use reflection.emit to modify the form. but i am finding every sting that is idenfitied from the form, is extracted as an instance, hence changing the string is only changing the instance of the strings , and not the instance of the form itself. hence i am not able so a correct display.

I have been trying for 3 weeks to solve these last two questions, Thanks in advance for helping me solve this.

Sweetu
  • 31
  • 2
  • Why don't you just create resource assemblies? – jgauffin Feb 16 '11 at 05:44
  • The actual app i am making is to pass it to a translator, i am not familiar with the other languages, and have been asking a friend to translate for me, she is unfamiliar with programming and sometimes i am getting complains that the translations dont have the same meaning as the words. Hence the nead for context, thats why the app. So she can visually translate the strings. – Sweetu Feb 16 '11 at 21:31

1 Answers1

0

I think you can't find a general solution to your problem with the texts that may appear in the textbox. Here is why:
If the texts are in the resource file, you could read them, but you still don't know where they are used. You would need to do a complex analysis of the source code to know, where the text is displayed. Just imagine this little scenario:

textBox.Text = GetCorrectText(connection.State);

GetCorrectText could look like this:

string GetCorrectText(ConnectionState state)
{
    return string.Format(Resources.ConnectionState, state);
}

Resources.ConnectionState might be "The connection is in the state {0}".

Its a simple example, but you would need to know or extract a lot of things:

  1. The text property of the TextBox class is the string that is shown to the user
  2. The Method GetCorrectText returns the text, so you need to parse it.
  3. The Method string.Format returns the text. Now you either would need to hardcode that for string.Format it should use the first parameter as the text that is displayed or you would have to parse string.Format to learn that fact.

The example shows something else: You wouldn't be able to translate the whole string that is being displayed, because part of it is the name of the enum value.

What I want to show you is that you need to make trade offs.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443