Multiple-Language Resource File (Sample Program)

New in April 2017.

 

The multiple-language resource file sample program demonstrates how to produce a multiple-language application based on a multiple-language resource file.  The application's resources are developed in just one language (single-language resource file).  By translating this single-language resource file with RC-WinTrans, a multiple-language resource file and multiple-language application can be created.  The sample (source code) was created with a Microsoft Visual Studio 2010 C++ project.  The graphical user interface (GUI) language of the compiled application can be changed at run-time.

 

The basic concept is that an application's single-language resource file will be translated with RC-WinTrans into several languages.  RC-WinTrans generates the target resource files- one for each language- on command.  These translated resource files will be included ("#include" statement) in the source (original) resource file.  The source resource file gets one include statement per translated resource file.

 

NOTE: The file concept used in this sample is not for creating one single multiple-language resource file.  Instead, two translated target files (for German and Japanese) are created by RC-WinTrans. These target files will be included (with an "#include" statement) in the source file.  After being compiled by the resource compiler, the result is the same as having the resource in just one file: a multiple-language resource file.  To see what this looks like, open the "scribble.rc" source resource file with a text editor and view the two include statements for the German and Japanese resource files:

#include "TargetRC\ScribbleGER.rc" // German resource file

#include "TargetRC\ScribbleJAP.rc" // Japanese resource file

 

Advantages

An application can be developed in just one set of resources, in one single language.  Resources in additional languages will be generated by RC-WinTrans.  A developer only has to maintain the resources of a single-language resource file (here: "scribble.rc").  RC-WinTrans’ change control permits the source resource file to be changed and expanded and the target resource files to be kept up-to-date with a minimum of work.

 

 

Sample Access and Files Overview

To edit the translations for this multiple-language "Scribble" sample, open the source resource file "SCRIBBLE.RC" from RC-WinTrans' Samples page.

 

 

image2.gif (5473 bytes)

Figure 1: File concept.  The source resouce file of the Scribble application (scribble.rc) with two include statements for the translated resouce files "ScribbleGER.rc" (German) and "ScribbleJAP.rc" (Japanese).

 

 

Primary files of the "Scribble.rc" translation project:

FILE NAME

DESCRIPTION

Scribble.rc

Source RC file of the "Scribble" sample application.  A single-language resource file with English as the original/source language.

MultiLangRC.rwtproject

RC-WinTrans project definition file.

MultiLangRC.fsmdb

Project database file (Microsoft Access database).

ScribbleGER.rc

German translation of the "Scribble.rc" source rc file.  A target file.

ScribbleJAP.rc

Japanese translation of the "Scribble.rc" source rc file. A target file.

 

 

Adding Include Statements in Source Files

In general, RC-WinTrans makes no changes to a source file.  The include statements in the source file, one for each localized file (target file), must be added manually by the developer using (here in this sample) MS Visual Studio.

 

EXAMPLE: Include statements in the source file "Scribble.rc" for two localized files- German ("ScribbleGER.rc") and Japanese ("ScribbleJAP.rc").

 

3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#include ""res\\Scribble.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#include ""TargetRC\\ScribbleGER.rc"" // German resource file\r\n"
"#include ""TargetRC\\ScribbleJAP.rc"" // Japanese resource file\r\n"

"\r\n"
"\0"
END


#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES

#include "res\Scribble.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#include "TargetRC\ScribbleGER.rc" // German resource file
#include "TargetRC\ScribbleJAP.rc" // Japanese resource file


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

 

 

Omitting Include Statements from Target Files

Because a localized target file is a copy of the source file, any include statements in the source file are also contained in the target file.  Include statements should be specified as to be "omitted from the target file" to avoid recursive inclusion at the time of compilation.

 

Procedure for avoiding duplicate include statements in the target file(s):

1.

Start RC-WinTrans and open the translation project.  The project can be opened from the Samples page or by opening the project file "MultiLangRC.rwtproject" or the database file "MultiLangRC.fsmdb."

2.

Set the include statements to be visible by selecting the "include" items in the Projects view (see Figure 2 below).

3.

Set all include files (.h, .rc, .rc2) to be omitted from the target file (see Figure 3).  This prevents include statements from being put in the target files another time.  Use: Edit menu | Attributes | Omit from Target File.

 

See also: "Omitting Resources from Target Files."

 

SUGGESTION: Use the "omit from target file" designation for images as well.  This prevents the images from being included in the target files a second time (since the images are already present in and will be taken over from the source at the time of compilation).

 

In the sample there is one translated bitmap- this bitmap has not been omitted.

 

 

Figure 2: File "includes" listed and selected in the main window's Text Table view.

 

 

Figure 3: The file includes after applying the Omit from Target Language command for the German and Japanese target languages.

 

 

^ TOP ^