2.6 Creating a Message File

You need to create a binary, ASCII message (MSG) file that can be linked in to your executable file. Typically, you link the English MSG file to your executable file and specify the language codes for each language for which you have provided translations. As your application runs, it then extracts the localized messages and prints them to the screen in the language you specified by its language ID.

The following steps assume that you are using XMsgUtil but provide the basic steps necessary to use either tool. For the specific DOS-based syntaxes and flags, see Using XMsgTool.

  1. To start the executable, double-click the XMsgUtil.exe (or XMsgTool.exe) file.

  2. Ensure that the Create MSG tab is selected.

    The following screen is displayed:

    Figure 2-2 Create MSG Tab Screenshot

    For the DOS-based syntax and the flags that are available for XMsgTool, see Creating an MSG File.

  3. Enter the name of your XLIFF file in the XLIFF Filename field (for example, myprog.xlf).

  4. Enter the name of the target path and file in the Target Path field (for example, c:\myproj\).

  5. Enter the name of the desired MSG file in the Msg Filename field (for example, myprog.msg).

  6. Check the flag options you want.

    For a description of the flag options that are available for XMsgTool, see DOS Create MSG Flags.

  7. To finish creating an MSG file, click OK.

  8. Link the English message modules.

    If the English message modules are the default user interface for your program, link them with the MESSAGES option in the linker definition file. Do not link language modules with your program (other than the default), but load them separately if they are needed.

    In CodeWarrior, use the following linker directive in a .def file:

       MESSAGES <message file>
       
  9. Code the program to access the appropriate message module.

    The NLM loader automatically loads and initializes the message module that corresponds to the user’s language (specified by the LANGUAGE command).

    Define the MSG macro to be an index into an array of messages and initialize the message array during startup by calling LoadLanguageMessageTable.

    For example:

       #define MSG(s, id)     myprogMesgTable[id] 
       ... 
        
       /* during program initialization... */ 
        
       BYTE    **myprogMesgTable; 
        
       LoadLanguagMessageTable(&myprogMesgTable, &msgCnt, 
            &languageID); 
        
       /* Later, during processing, we detect an error and 
             print a message ... */ 
        
       NWprintf(MSG("MYPROG: Insufficient memory.\r\n", 132));
       

    You are now ready to test your localized program.