Forum: Multi-Language Add-In for Visual Studio

New idea for hiding strings

Germany

A basic feature of the Add-In is that you can hide strings which do not require translation. When you hide a string, the Add-In adds the comment //MLHIDE or 'MLHIDE to the end of the line. If you like, you can add this comment by hand, without using the Add-In.

This method has the advantage of being very simple.

It has the disadvantage of being ambiguous when there are multiple strings on the same line.

It would clearly be better, it the Add-In could mark a specific text as 'hidden', but I have never thought of a good - and simple - way of doing it. In C# the Add-In could add a comment /*MLHIDE*/ immediately after the string, but this would not be possible in VB (which has no embedded comments). I also think this makes the code less readable (and is ugly).

Now I have a different idea. How about putting the string in double brackets?

For example

MessageBox.Show ( "Message", (("Title")) ) ;
would indicate that "Title" should not be translated, but "Message" should.


I think this would be legal code in C#, VB and C++. I think it passes the test of simplicity, and I don't think it messes the code up too much. It would look a bit odd for a single function parameter, which would then be in triple brackets, but I think that is OK.

Obviously, this would require explanation to someone seeing it for the first time, but the MLHIDE comment also requires explanation.

Is this a good idea? Or is it stupid?
Does anybody have an opinion?

Phil

Actually, there is another problem with the MLHIDE comment, which I only recently discovered. The Add-In detects the VB line continuation character and places the comment at the final end of the continued line. This works fine. However, Visual Studio 2010 introduced implicit line continuation in VB, meaning that you can leave the line continuation character away if it is not ambiguous. The specific situations are listed here. The Add-In does not detect the implicit line continuation, which means it might insert the MLHIDE comment at an illegal position.

I'm not sure... It looks ok for want of a better word "text" strings, but what about things like format masks? For example:

Now.ToString("yyyyMMdd_HHmm") 'MLHIDE

Just as a reminder we also use 'MLHIDEON and 'MLHIDEOFF a lot which does not really get in the way if nothing in the whole method should be translated for example:

Public Sub DoSomething() 'MLHIDEON
...
...
End Sub 'MLHIDEOFF


I think the double quotes are a good idea for multiple strings on the same line. But I like //MLHIDE better if you need to hide everything on an line. So I'll suggest you'll support both :-).