Loading...
 
Multi-Language Add-In for Visual Studio

Multi-Language Add-In for Visual Studio


Add-In deletes Control.Text !

We use your Add-In Version 4.60.0020 in Visual Studio 2008 (C#).
We are working on an application with a lot of forms and classes. From time to time after we have created a few new forms we translate texts inside the Add-In or export, let translate and import texts.

At first we worked with Version 4.54.0002. It worked quiet well with some difficulties with Infragistics controls but it was ok.
For nearly 2 months we worked with version 4.60.0005 because the possibility to use a xml-file instead of a mdb-file is very attractive. But unfortunalety we got some problems (see below).
Today I start working with Version 4.60.0020 but the problems are the same as with Version 4.60.0005:

1.
Suddenly the texts of two label controls of one form are deleted. The control is still there but with the 'new' property Label1.Text = "". Inside the Add-In the property Label1.Text does not appear anymore!
The texts for the other languages are the same as the actual texts but I think that does not matter. If I put in the right texts again and scan the project again the Add-In does not see the propery Label1.Text !
Maybe I can create a new label to solve the problem but I want to know why and under which circumstances this "automatical deletion" takes place.

2.
Suddenly all the texts of one form (and the corresponding actual texts inside the Add-In) are replaced with the property name itself that is "label1.Text", "label2.Text" and so on. Why ?


3.
On the other hand if I delete the text (-> actual text) of a Columnheader inside a ListView-control the Add-In or whatever replace the empty string with the default text 'Columnheader'. I do not know what I have exactly to do in order to get an empty string in all languages and the actual text.


As a hint: I nearly always chose the option "Determine resource names" and I often chose the option "Clean up string resources".

Finally we need this Add-In and beside these strange things we are really content with it.

Katja

Germany

Hello Katja,

I can explain some points, but I can't reproduce the errors, so I will need a little bit more information. Lets start with the things which I can explain, firstly...

Handling empty strings.

By default, the Add-In does not show properties which contain an empty string. This explains why your Label1.Text does not appear in the Add-In, when it contains an empty string.

You can change this option via the settings dialog. Click on the Add-In Settings button
Image
and then look on the options tab.
Image
There are two options to control the handling of empty strings in controls and in the source code.

I think that this default behaviour is sensible, because you almost never want to translate an empty string. In fact, I consider it a bad practice.

How does Determine resource names work?

Your second error is related to the option Determine resource names. This is basically a dirty trick to support Infragistics controls. I have always had great difficulty determining the resource names used by the Infragistics controls. Finally I came up with a sledge hammer approach, which works like this:

  • Make a backup copy of the .resx file.
  • Modify the .resx file by making the value of each string resource identical to the name of the resource.
  • Scan the properties via the designer window. This is basically the same as the normal controls scan, except that the content of each property is identical to the resource name associated with it. The Add-In stores the resource names in the project database.
  • Restore the original .resx file from the backup.


For example, in one test project I have a property UltraToolbarsManager1.Tools("Cut").SharedProps.Caption which uses the resource name ButtonTool6.SharedProps.Caption.

An important point is that the original .resx file is restored in the Finally block of a Try/Finally statement, so this step should be performed, even if an error occurs during the operation.

Now to your specific problems:

1 Disappearing text

Sorry, I can't reproduce this or figure out when it might happen. Can you give me some more information about what seems to cause the error. Does it happen after exporting the resources, or scanning the project, or what? The more information you can give me the better.

2 Property value=name

Now that I have described how the determine resource names feature works, it seems clear that this has somehow gone wrong. Even though the backup file is restored in a Finally block, it looks like it has been restored. Do you remember if there was any error message?

Can you please look for a file called .resx.mlbak. If it exists, then you can replace the .resx file with this backup file by hand.

Meanwhile, I will have to test this more, and try to find where it can go wrong.

By the way, you only really need the determine resource names option with Infragistics controls, and you only need to do it once each time you modify the control.

3 Listview column headers

Again I can't reproduce this error. Do you mean that the text "ColumnHeader" is appearing at runtime, or in the Add-In? If it is at runtime, then it must be in the resource file.

Phil


Thank you for your quick answer.

The options for empty strings are set as you suggest. I think it is not really useful to change these behavior.

I know that the support of the Infragistics control are really difficult and unfortunately we use a lot of them. I will use the option “Determine resource names??? only if I have changed something in an Infragistics control.

1. At the moment I can’t remember what I had done before the texts disappeared. I will find it out – hopefully it will happen again… The actual problem is the following: If I fill in the text again so that the property Label1.Text = “Plant??? and I rescan the project, the text doesn’t appear in the Add-In ! At runtime the text appears. I think something strange is happened to this Label so that the Add-In can’t “read??? it ?!

2. There was no error message. There is no file with the ending .resx.mlbak. I just can find a file in the directory _sgbak with an ending .resx.2009-02-25.8-45-30.0129 and other files with other dates and times. I am able to repair it and I will try to find out when it exactly happen.

3. I change the name of a Label control. Then (without scanning oder saving or anything else (!) a line is written into the method

private void InitializeComponent() of the corresponding form:

this.chIcon.Text = global::Branscheid.AES.Administrator.MultiLang._766;

This line results in an error so that I have to delete this line. After that the Text “Columnheader??? appears in the property chIcon.Text.
Sorry that I did not realize this connection up to now.
But what is the reason for the writing of this line ? What must happen ? The changing of the name of the Label control was the right thing by chance!

I hope you can help me.

Katja

Germany

Hi Katja,

With regard to your 3rd problem, I have seen this before, but I have not personally had the problem for a long time. In fact, I thought it was solved.

I can't explain why it happens. The Add-In does not modify the function InitializeComponent() at all. This is only performed by Visual Studio itself. However, I'm pretty sure that it is related to opening and closing the designer windows.

Since it seems to occur using the Infragistics controls, I am going to install the latest trial version and perform tests using the sample applications. I hope that I can reproduce the error, and then maybe I can fix it.

By the way, please don't think I have a bad impression of the Infragistics controls. On the contrary, they appear to make great products.

Phil