Export (0) Print
Expand All

Chapter 4 Preparing the User Interface for Localization

Glossary

  • Resource: (1) An element such as a string, icon, bitmap, cursor, dialog, accelerator, or menu that is included in a Microsoft Windows resource (.RC) file. (2) Any item that needs to be translated.

The process of internationalizing and localizing software involves a number of interrelated issues—character sets, language dependencies, cultural conventions, translation—and trying to sort them out can be a daunting task. To help you get a good handle on them, this chapter and the remaining chapters take a functional approach to the discussion of software development by asking the following basic—but critical—questions: What are the necessary steps for creating localized editions of a Windows-based application, and what does each step involve?

As discussed in Chapter 2, setting up your program source files so that the user interface can be easily localized is a crucial beginning step in creating globalized software. This chapter contains an in-depth discussion of Win32 resource files, which are a convenient mechanism for isolating, editing, and compiling the localizable elements of an application's user interface.

Some developers have been reluctant to use Windows resource files in the past because the files were considered slow; Windows 3.1 compiled 16-bit resources into separate segments and retrieved individual resources based on a linear search. Win32 doesn't use segments, so resources are compiled into a single object file that is linked to the executable like any other object file. Win32 uses a sorted resource table and a binary search for fast lookup of individual resources. It also indexes resource elements by language as well as by type and name. You can compile multiple-language resources in a single executable or into separate dynamic link libraries (DLLs) and switch the language of your program's user interface at run time, a feature Windows 3.1 didn't support.

Using Win32 resource files makes it possible to produce a single binary executable that works for all language editions of an application. To create a different language edition of a program, you change only the resources. Figure 4-1 lists the steps in the process of localizing a user interface using this method.

  1. Put all native-language localizable elements in one or more resource files.
  2. Link the resources to the program executable or put them in a DLL.
  3. Translate text elements and resize dialog boxes using localization tools.
  4. Test the localized program and change the localized files if necessary. Retest.
  5. Add, delete, or change all localizable elements in the native-language resources.
  6. Merge the changes into localized resources.
  7. Repeat steps 2–6 until the program is ready to ship.
  8. Optional: Add support for multiple-language resources or create extensible language support for the user interface by using DLLs.

Figure 4-1. Steps for localizing a user interface.

Although you could invent your own mechanism for dealing with localizable user interface elements (Windows allows you to define your own resource types using RCDATA declarations), you would also have to create your own editing and localization tools, which is not as easy as it sounds. Creating custom localization tools can be more complicated than creating your application. Don't risk your ship date by depending on the delivery of custom tools.

The Win32 SDK ships with tools that you can use to create, edit, and compile Win32 resources. Figure 4-2 lists project files and the SDK tools used to edit and compile them. Note that the SDK does not ship with a source code compiler—you'll have to purchase that separately.

Figure 4-2. Tools shipped with the Windows Software Development Kit.

One option is to use Microsoft Visual C++, which provides an integrated environment convenient for creating, editing, compiling, and linking source code and Windows resources. (See Figure 4-3 below.) Visual C++ 2 does not yet support message files, so if you use Visual C++, you will need the message compiler that comes with the SDK. Both Visual C++ and the SDK ship with helpful sample code.

Figure 4-3. Visual C++ 2's integrated development environment.

 

 

 

 

Show:
© 2014 Microsoft