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

Multi-Language Add-In for Visual Studio


Version 5 - Support for named resources

Germany

All previous versions of the Add-In have used the function ml_string() to localize texts in the program source code. This goes right back to the first version for VB6.

This function has two characteristics:

  • it uses a numeric string ID
  • it includes the original string as a parameter, but really it is just a comment


I personally have never liked using resource names as place-holders for texts in the source code. I prefer to see the original text, which I find makes the code more readable.

However, in most points I tend to follow the principle: "Do it the way Microsoft recommends". Anything else is like swimming against the stream. And there is no doubt, Microsoft recommends using named resources in the program source code.

(Although resources for native code (C++ or VB6) always have numeric IDs, this is not allowed in a .resx file. Therefore the Add-In prefixes the values with an underscore. This is an example of swimming against the stream.)

In version 5 of the Add-In, I have given up my resistance to using named resources. There are now two methods to localize strings in the source code:

  • using named resources
  • using ml_string()


When you start working with a new project, you have to choose between these two methods. If you select named resources, then neither the MlString module, nor the resource file MultiLang.resx will be added to the project. You can modify this option later using the project properties dialog, but that won't automatically change any prior localization.

Internally, resources are still assigned numeric IDs, but strings which are used in the source code are also given resource names and stored in the standard resource file resources.resx.

All named resources are also shown in the "Additional Resources" tab. (I will probably remove the word "Additional" soon.) The resource names are based on the original text, so for example the resource name for "Hello World" would be Hello_World. The names are limited to about 30 characters and may have a numeric suffix for disambiguation. If you don't like the name, then you can edit it in the "Additional Resources" tab. (I'm not sure that this is good user interface, but I am reluctant to add another column to the source code grid.)

At present there is no way to remove unused named resources. The function "Remove unused String IDs" ought to do this, but I know it needs fixing.

The previous version (4.7x.0136) is still available on the download page (in case I have broken something critical), but version 5 is now the official version. I look forward feedback from users on this new feature.

Phil

Great news!

A way to convert existing projects (that use numeric strings) would be very welcome. And a way to remove unused named resources might be necessary in the future as well.

Germany

I agree, these features are missing.

I have just found a more critical problem. If a string is used a multiple places and you edit one of the translations, the Add-In asks whether the change should be applied to all occurrences. If you answer with no, the Add-In will generate a new String-ID for the edited text. Using named resources, it might have to generate a new resource name as well. I'm pretty sure it doesn't, which is a fairly critical error! This is one that I hope to fix quickly.

Phil

Yes an option to convert existing projects, including removing the unnecessary files would be nice for the future.

I have just noticed that the project properties for an existing project has the use named resources ticked, does that mean that new strings will use named resources whilst updates to existing ones will continue with the ml_string way?


Martin

Germany

The option "use named resources" should not be selected for old projects.

That was an error, which I have fixed in version 5.0x.0008. If you have opened the project with version 5.0x.0006 or 5.0x.0007, then you will have to uncheck this option manually.

However, if it is set, then that would mean that new strings would use named resources whilst previously selected strings would continue to use ml_string().

(Simply unselecting and then reselecting a string should be enough to change it to a named resource, but I will certainly add a feature to do this automatically.)

Phil