New way to hide strings in the source code
Hiding strings with the MLHIDE comment
Multi-Language has always had a simple way of hiding stings in the source code.
By adding the comment //MLHIDE or 'MLHIDE to the end of a line, the strings on this line are marked as hidden, which means that they do not need to be translated.
e.g.
string sql = "SELECT * FROM MyTable" ; // MLHIDE
In almost all cases this is good enough. The best thing about this method is how simple it is.
The disadvantage is that marks the whole line as hidden, and not as individual string. This is a problem if there are two or more strings on one line, for example as parameters to a function.
Implicit line continuation in Visual Basic
Recent versions of Visual Basic have introduced another problem, with a feature called implicit line continuation. In Visual Basic, you can only put a comment at the end of statement, which is usually a single line. Traditionally, you could continue a statement onto the following line by placing an underscore at the end of the line.
Multi-Language understands the traditional method of line continuation and handles these lines as a single statement.
With implicit line continuation, you can - in some circumstances - leave the underscore away and the VB compiler recognizes that the statement is continued on the next line.
Multi-Language does not understand implicit line continuation and does not behave correctly. If this is a problem, you can always add the underscores after all. However, the automatic formatting of VB code in Visual Studio 2015 actually removes the underscores if they are not necessary, breaking the simple workaround.
The rules for implicit line continuation are too complex for the fairly simple code scanner in Multi-Language so I have been looking for a better solution.
Hiding strings with double brackets
My solution is to define a completely new syntax for hiding strings, by enclosing the strings in double brackets,
e.g.
string sql = (("SELECT * FROM MyTable")) ;
So far as I can tell this is a legal syntax in VB, C#, C++ and javascript and has no other meaning.
If there are multiple strings on a single line, then you can easily hide only one of them.
e.g.
MessageBox.Show ( "Do you want to exit?", (("My Application")), MessageBoxButtons.YesNo, MessageBoxIcon.Question ) ;
To be honest, I think this idea might be brilliant, or it might be completely stupid. I half expect someone to point out a fundamental problem which I have not thought of. Nevertheless, I have implemented it in version 6.01 of Multi-Language.
However, I do think that this new syntax is more difficult to understand and will be confusing to programmers who are not familiar with it. A new programmer in a team will surely look at it and think "what is this nonsense?".
Implementation in version 6.01 of Multi-Language
Multi-Language now has an option to select the default way to hide a string.
You can change this option in the "General" page of the Multi-Language options, as shown here:
In addition, the first time that you hide a string in the source code, a message box will appear to explain the new option.
Whichever option you select, you can always hide a text with the other option, via the context menu on the sun/moon symbol.
Finally, I have used a new symbol in the sun/moon column, which was meant to look like a solar eclipse. I'm not sure that I will stick with this, because its not a very good icon and it's a bit stupid anyway.
Phil