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

Multi-Language Add-In for Visual Studio


afxres.rc, standard mfc symbols

Hi again,

I currently use two languages in my VS 2005 c++ MFC application:
German (Main language) and English (USA).

My problem is that the add-in doesn't include the afxres.rc for the english language, which contains the symbols of the MFC standard dialog boxes, like AFX_IDP_ASK_TO_SAVE.
So when I choose 'English' and a standard dialog should pop up, it is empty in 'RELEASE' and throws an error in 'DEBUG'.
For German 'l.deu\\afxres.rc' is added correctly.
I can solve this problem manually by adding the line '#include afxres.rc' to the english part of the ml resource, but it is lost again each time the addon recreates ml resource of course.

What I cannot fix is that I always get german buttons in these standard dialogs ("Ja", "Nein", "Abbrechen"). Not sure if this is a problem of my application or of the plugin, though.

Thanks.

Ben

Germany

Hi Ben,

I want to add some automatic support for this problem, but I haven't decided how to do it yet. First, let's see whether we can find a quick solution for you.

When I generate a new MFC project (with VS2010) it adds a block of code like this to the .rc file.

Code to include afxres.rc (German
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
LANGUAGE 7, 1
#include "res\\MFC_Test_003.rc2"  // Nicht mit Microsoft Visual C++ bearbeitete Ressourcen
#include "l.DEU\\afxres.rc"       // Standardkomponenten
#include "l.DEU\\afxprint.rc"     // Ressourcen für Drucken/Seitenansicht
#if !defined(_AFXDLL)
#include "l.DEU\\afxribbon.rc"    // Ressourcen für MFC-Menüband und -Steuerleiste
#endif
#endif


I think that the easiest thing would be to add a second block of code immediately after this, something like:

Code to include afxres.rc (English
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#include "res\\MFC_Test_003.rc2"  // Nicht mit Microsoft Visual C++ bearbeitete Ressourcen
#include "afxres.rc"             // Standardkomponenten
#include "afxprint.rc"           // Ressourcen für Drucken/Seitenansicht
#if !defined(_AFXDLL)
#include "afxribbon.rc"          // Ressourcen für MFC-Menüband und -Steuerleiste
#endif
#endif


I have changed three things:

  • replaced AFX_TARG_DEU with AFX_TARG_ENU
  • replaced LANGUAGE 7 with LANGUAGE 9
  • removed the subdirectory l.DEU in 3 include statements


Normally, I would use the symbol LANG_ENGLISH instead of the value 9 and the symbol SUBLANG_DEFAULT instead of the value 1. For some reason Microsoft now generate code using numeric IDs. I have no idea why.

If you specified English(USA) to the Add-In, it might be better to use SUBLANG_ENGLISH_US, but that also has the value 1.biggrin

If you simply specified English, then the Add-In will have used SUBLANG_NEUTRAL (=0), so you might have to do that as well. Actually, I'm not sure how well SUBLANG_NEUTRAL works with MFC. So far as I can tell, Microsoft never use it.

There is another, very obscure way to enter the same code. You may have noticed a comment like:
// Generated from the TEXTINCLUDE 3 resource.
or
// Aus der Ressource TEXTINCLUDE 3 generiert.

The same code is also present at the top of the .rc file in a series of TEXTINCLUDE resources, which you can edit via a dialog in Visual Studio.

You can select ''Resource Includes ..." from the context menu in the Resource View.
Image

It brings up a dialog with three text areas, the third of which contains the code I discussed above.
Image
If you paste the code into this text box and then click on OK, Visual Studio stores it in the TEXTINCLUDE resource and updates the real code in the .rc file as well.

I expect that there is some purpose to this mechanism, but I must admit I can't see any. It looks needlessly complicated to me.

With regard to the buttons OK, Cancel, Yes, No, if they are generated by the windows MessageBox function, I don't think that there is anything you can do about it. I think that the same is true of the standard file open dialog. These appear in the language of the operating system.

Phil

Hi Phil,
Thanks, that helped me out.
I actually tried to do that in the ml resource already, but I didn't think of doing it directly in the main resource file.
Adding the complete block like you described didn't work, though.
Normally, the addin creates some lines for each additional language to enclose the specific resource data in it:

Created by the addin
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#endif //_WIN32

STRINGTABLE PRELOAD DISCARDABLE
BEGIN
(...)
#endif // Englisch (USA) resources

When I copy the whole block, the addin seems to think that the lines are already present and doesn't encase the additional resources at all, so they are loaded twice when you choose the wrong language and you get an error.
Anyway i just added

Manually added code
#if defined(AFX_TARG_ENU)
#include "afxres.rc"          // Standardkomponenten
#include "afxprint.rc"        // Ressourcen für Drucken/Seitenansicht
#endif
instead, which worked just fine.


>With regard to the buttons OK, Cancel, Yes, No, if they are generated by the windows MessageBox function, I don't think that there is anything you can do about it. I think that the same is true of the standard file open dialog. These appear in the language of the operating system.
<
I wasn't aware of that, that is even better because it means that I have to do nothing at all ;)

Thanks again!

Ben

PS: How can I quote in this forum (quotetags?)?

Germany

Hi Ben

I have just uploaded a new version (4.7x.0065), which inserts statements to include afxres.rc and similar files for specific languages.

Phil

Phil wrote:
I have just uploaded a new version (4.7x.0065), which inserts statements to include afxres.rc and similar files for specific languages.


Thanks, i will try it.


Germany

Hi Ben

Ben wrote:
PS: How can I quote in this forum (quotetags?)?

That is the super-duper format, written as follows:

 
Ben wrote:
PS: How can I quote in this forum (quotetags?)?

Unfortunately, there is no single button to insert that syntax.

The simplest ways are probably to put it in italics,
or in a box.
There are buttons for both of these above the edit field.


The syntax for the forum isn't really explained anywhere. In fact, it supports the complete Wiki syntax of Tikiwiki. The QUOTE syntax is a so called plugin.

The wiki-editor has a useful wiki-help button, which is missing in the forum. With a bit of effort I could certainly get it to appear. On the other hand, I'm about 4 major versions behind the current version of TikiWiki, so I ought to get up to date first.smile

Phil


Hi Phil,
Somehow that didn't work for me.
I installed Version 4.7x.0066 but the addin seems to add nothing more to the rs file.
Is there an option which I have to set or something like that?

Regards,

Ben