. Home Feedback Contents Search

Country Specific Resources 

Back Up Next

Creation of Country Specific Resources

Project Organization

Although the intent is to create a DLL’s for each supported language, there is only a single RC file that is shared between the main project and the resource project. This RC file will contain separate sections for each of the target locales. Under the main project is a resource only project. It is this resource only project that will be responsible for generating the DLL that will contain locale specific resources. Each locale gets its own configuration in the resource project file. The configurations allow for specification of the output name (<base><locale 3 letter suffix>.dll) and equates in the Resource tab to control which resources will be included in the local specific resource only DLL.

If the main project is Abc and is resides at C:\dev\Abc, then the associated resource project will be named AbcRes and will reside at C:\dev\Abc\AbcRes.

Base Project Resource Tab Changes

Since the expectation is that the project will be getting its resources from some other DLL we don’t want the project to include resources. To prevent the build from generating its own resources, an equate is added to the RC compile step. Adding the preprocessor definition AFX_RESOURCE_DLL results in the expectation that the resource will be loaded at run time from a resource DLL.

Creating Locale Project

Although there are multiple supported locales, there is only a single project to contain the multiple locales. Additionally, the project does not use its own RC and Resource.h file. Instead, it will make use of the main project’s files.

Creating Locale Resources

During development, the initial population of the resources for each locale is accomplished by making a copy of the original English version to a language specific area in the RC file. No attempt is made to actually translate or in any other way tailor the resource in a locale appropriate manner at this time. It will be the responsibility of an external localization company to take care of those details. The developer is only responsibility for the creation of the resource to be localized.

The actual copy of a resource itself is very easy. The resource to be copied is selected and a command given to insert a copy of it.

The country to receive the copy is specified as part of the copy operation. When the Insert Copy command is given, MsDev will automatically ask what language is to be associated with the copy. It is a simply matter to scroll through the combo list to select the appropriate language.

Each resource needs to be duplicated for

  • French (France)
  • German (Germany)
  • Italian (Italy)
  • Japanese
  • Spanish (Modern)

Warning for Resources With Associated File

While most resources are fine with a simple copy, there is an exception to this process. If a resource has an associated file, the resource copy will point to a copy of the original file. The new file does not exist in the source repository so the project will build locally but fails on other machines because they won’t get the newly required files. There are two things that can be done – manually add the newly created file copies to source control or point the resource copies back to the original file. If there’s no difference between the original and the copy then it doesn’t make a lot of sense to have the copy around.

Although it is possible to use resource UI tools to point the resource copy back at the original file, it is easier to repair the problem by manually editing the RC file directly.

As an example, let’s assume that the module has an image list. Image lists have an associated bitmap file. The original is in the RC file as

IDB_IMAGELIST           BITMAP  DISCARDABLE     "../../../UXDImages/icn_domain.bmp"

Since all of the languages are going to share the same image list bitmap, it makes sense that they all point to the same bitmap. Originally, they will be named something like this:

IDB_IMAGELIST           BITMAP  DISCARDABLE     "../../../uxdimages/bmp00001.bmp"

Copy the desired line and then search for and replace all of the other IDB_IMAGELIS lines.

The second part of this process is to remove the copy file. Open up the Resource Files part of the project, select the resource files to be removed and hit the Delete key. This doesn’t delete the files from your hard disk but will remove them from the project.

In the following screen shot, the additional localized resource copies were done from the resource project, not the main project, so the additional files were associated with that project. In this case, there was an image list that was duplicated five times. The bitmaps were selected and then removed from the project.

Disable Resource Build In Main Project

If the module is compiled at this point, it would still contain resources. The aim is to produce a binary that contains the executable and depends upon a run time loaded resource only DLL to provide the localized UI elements.

The remaining step is to create a configuration that will create a locale specific resource only DLL. By convention, a DLL project is created under the base project and named baseRes. The RC and resource.h file from the base project are directly included in the resource project. A configuration for each of the supported locales is added to this project.

Resource Only Project

In the Preprocessor definitions for each configuration, an appropriate target, AFX_RESOURCE_DLL and _WIN32 are all specified.

All configurations must specify a target locale, even the default English build. The currently supported targets are

  • AFX_TARG_DEU
  • AFX_TARG_ENU
  • AFX_TARG_ESP
  • AFX_TARG_FRA
  • AFX_TARG_ITA
  • AFX_TARG_JPN

 As an example, assume that the base project is Xzy, it produces an executable and there are three supported locales, English, French and Italian. Under Xyz would be another directory, XyzRes and it would contain a simple DLL resource only project XyzRes.dsp. Inside of this project are three locales that build in release, debug, Unicode release and Unicode debug configurations, giving a total of 12 configurations.

Configuration

Output

XyzResEnu – Win32 debug

debug\XyzENU.dll

XyzResEnu – Win32 release

release\XyzENU.dll

XyzResEnu – Win32 Unicode debug

Unicode_debug\XyzENU.dll

XyzResEnu – Win32 Unicode release

Unicode_release\XyzENU.dll

XyzResFra – Win32 debug

debug\XyzFRA.dll

XyzResFra – Win32 release

release\XyzFRA.dll

XyzResFra – Win32 Unicode debug

Unicode_debug\XyzFRA.dll

XyzResFra – Win32 Unicode release

Unicode_release\XyzFRA.dll

XyzResIta – Win32 debug

debug\XyzITA.dll

XyzResIta – Win32 release

release\XyzITA.dll

XyzResIta – Win32 Unicode debug

Unicode_debug\XyzITA.dll

XyzResIta – Win32 Unicode release

Unicode_release\XyzITA.dll

Delete RC and Resource.h

When the Resource project is created by the project wizard, by default, it contains an RC and a Resource.h file. Delete both of these from the project and physically from the local drive before adding the project to source control.

The newly created project wants to include the Resource.h file in the main header file created by the application wizard. Since the project no longer has its own Resource.h file, you can either alter the project so that the header can find the Resource.h it is using or just delete the reference to the file in the first place. The project doesn’t need to know anything about Resource.h when it compiles the CPP file so there’s no point is adding a path to the project. Simple select the offending reference and delete it.

Localization Time

At localization time, the project’s RC and its resource.h are sent to the localizers. They insert the appropriate values for their locale and return the RC. This RC is merged with the project’s RC.

Kit Time

At kit build time, the base module and all of its localized DLLs are included in the installation.

Installation Time

At installation time, the base module and any user selected languages are installed on the client machine.

Run Time

At run time, when the base module does its initialization, it checks to see what language is in effect. The appropriate localized DLL is loaded using LoadLibrary. Thereafter, any resource operation uses the handle returned from the LoadLibrary to fetch the resource

Back Up Next

Hit Counter