Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Build localized apps as separate executables

0.00/5 (No votes)
26 Jul 2002 1  
How to build a separate executable for each language version.

Sample Image - BuildResSeparately.jpg

Overview

Microsoft Visual Studio 6.0 offers only a framework to build all resources into one executable file. This can be disturbing if you want to localize your application into completely separated files. Fortunately VC++'s wide environment allows you to achieve this with a couple of steps...

Steps:

  1. Rename your default Demo.rc file to Demo_EN.rc or other names depending on the language version.
  2. Create a new default Demo.rc file which would look something like this:
    //Microsoft Developer Studio generated resource script.
    
    //
    
    #include "resource.h"
    
    
    #define APSTUDIO_READONLY_SYMBOLS
    ////////////////////////////////////////////////////////////
    
    //
    
    // Generated from the TEXTINCLUDE 2 resource.
    
    //
    
    #include "afxres.h"
    
    
    ////////////////////////////////////////////////////////////
    
    #undef APSTUDIO_READONLY_SYMBOLS
    
    #ifdef APSTUDIO_INVOKED
    ////////////////////////////////////////////////////////////
    
    //
    
    // TEXTINCLUDE
    
    //
    
    
    1 TEXTINCLUDE DISCARDABLE 
    BEGIN
    "resource.h\0"
    END
    
    2 TEXTINCLUDE DISCARDABLE 
    BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
    END
    
    3 TEXTINCLUDE DISCARDABLE 
    BEGIN
    "#ifdef MYLANGUAGE_CZ\r\n"
    "#include ""Demo_CZ.rc""\r\n"
    "#endif\r\n"
    "\r\n"
    "#ifdef MYLANGUAGE_EN\r\n"
    "#include ""Demo_EN.rc""\r\n"
    "#endif\r\n"
    "\0"
    END
    
    #endif // APSTUDIO_INVOKED
    
    
    
    #ifndef APSTUDIO_INVOKED
    ////////////////////////////////////////////////////////////
    
    //
    
    // Generated from the TEXTINCLUDE 3 resource.
    
    //
    
    #ifdef MYLANGUAGE_CZ
    #include "Demo_CZ.rc"
    
    #endif
    
    #ifdef MYLANGUAGE_EN
    #include "Demo_EN.rc"
    
    #endif
    
    ////////////////////////////////////////////////////////////
    
    #endif // not APSTUDIO_INVOKED
  3. Add the standard resource file (renamed to Demo_EN.rc) into the project (Menu/Project/Add To Project/Files)
  4. Go to Menu/Build/Configurations and add appropriate build configuration (Add... e.g. Release English, Copy from: Release)
  5. Go to Menu/Project/Settings, select your newly added Release English configuration
    • Switch to General tab, change the intermediate and output files location - just enter Release
    • Switch to Link tab and change the output file name to Release/Demo_EN.exe
    • Switch to Resources tab, Resource file name: Release/Demo_EN.res, preprocessor definitions: insert the string MYLANGUAGE_EN, change the Language to English (if not selected)
  6. Follow steps 3-5 for each language version you want to build
  7. For each new language version, add these lines into Demo.rc file:
    "#ifdef MYLANGUAGE_CZ\r\n"
    "#include ""Demo_CZ.rc""\r\n"
    "#endif\r\n"
    "\r\n"
    #ifdef MYLANGUAGE_CZ
    #include "Demo_CZ.rc"
    
    #endif

Note: For ATL projects you must keep the typelib in Demo.rc:

1 TYPELIB "Demo.tlb"

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here