What Do We Localize When We Localize Software?

Up to this point we have described in general what object-oriented programming is. It is a form of programming that basically uses windows and pre-defined objects and attaches "program code" to the objects or windows. Below you see the output of a Visual Basic program called "Hello World." This program consists of how many objects?

Answer: 4

This is not strictly speaking correct, but there are only four objects here we need to worry about localizing. Let's count them:

1 window, with a window title consisting of the string "Hello World!"

1 label, or text field currently set to the value "Written by Gregory Shreve"

1 edit box, currently set to the value "Hello world!"

1 command button, whose caption currently reads Ok.

wpeB.jpg (13402 bytes)

The window title, the text field value, the command button caption and the possible values of the edit box are set at design-time. They are set by the program code and either appear with no user action required (as in the case of the Window Title, the Text Field and the Command Button Caption) or they appear after a user takes some action (the value of the edit box "Hello world" only appears when the command button is clicked). Whether an action requires a user action or not, all the strings coded into a program must be localized. Strings can appear in many contexts. How are the values of these strings set by the programmer?

There are several methods. In an integrated development environment it might be possible just to use a WYSIWIG program editor to set one of the properties of the appropriate object. Let's take for example one of the objects above, the window.   A window is an object and, as we know has properties whose values can be sent by sending certain messages.

To understand how a programmer sets a string into an object we first need to know:

1. what kind of object the object is; once we know that we know

2. what kinds of properties it can take and then

3. we can set its value.

First I will set the window title of the window above to "Hello World!" using a WYSIWIG program editor, then I will set it by writing a little piece of a program.

1. Since the object I want to manipulate is a windows object (note that the name of this particular window, an instance of the Windows object class, is frmMain). I need to see what properties it can take. I right click on the object itself with my mouse (in the IDE) and

2. I see a list of the properties (messages) it can respond to. Note that among the properties listed is the property CAPTION.

3. In the WYSIWIG editor I can simply type in the value "Hello World!" next to the name of the property and the property is set. The window caption will appear as it does above.

wpe1.jpg (27817 bytes)

This is not the only way I can set this property. I could also do it with a program:

frmMain.Caption = "Hello World!"

Notice the structure of the line above:

NameOfObject.PropertyofObject = "String Value"

Here is another example. In the little program above when the user clicks the command button (the one labeled OK) the words "Hello world!" appear in the blank edit box.

As a programmer I can't set the Text property of the Text1 object (Text1.Text) just by using the program Property Editor. Instead I leave the property unset (default is set to blank). I have to write a program to set it that is executed when (and if) the command button is pressed.

wpe2.jpg (17856 bytes)

Here is the code activated by  the command button when it is clicked. wpe3.jpg (1244 bytes)

One of the things it is important to understand about object-oriented programming in addition to the concept that objects have names and properties, is that they respond to events.  O-O programming is sometimes called "event-driven."

So, when I write the little program I have to do two things:

1. specify which object will have the program code attached to it and

2. which event will activate it (Click, Double Click, Mouse Over, GetFocus, etc.)

 

Now, just so we get things straight, I want:

the Text1.Text  property, currently blank,  of the edit box object whose  name is Text1 wpe5.jpg (1555 bytes)


to be set to "Hello world!"

when I click the command button object,  whose name is Command1   wpe3.jpg (1244 bytes)

 

So, I attach the following code to Command1:

Private Sub Command1_Click()
Text1.Text = "Hello, world!"
End Sub

Note that it sets the Text property of the Text1 edit box instance to "Hello, world!" The notation _Click() attached to the name of the object means that this program will execute if and only if the command button undergoes a click event (a mouse is clicked on it.)

and the following is the result: wpe6.jpg (1673 bytes)

 

Object that Contain Strings That Need to Be Localized

Well it is clear so far that text strings comprise a great part of the linguistic material in software that has to be localized. It is also true that strings can be assigned to a great many different kinds of objects:

wpe7.jpg (50379 bytes)

Some of the objects above display strings (the File, Drive, and Directory boxes) when they display file and folder names, but these strings are not coded in the software and are not localized. The other kinds of objects,

almost certainly will need to be localized.

A major class of objects to be localized are called controls.

Controls

The Button Control Class

wpeC.jpg (1839 bytes)

A button control is a small rectangular child window that the user can turn on or off by clicking it with the mouse. Button controls can be used alone or in groups, and can either be labeled or appear without text. Button controls typically change appearance when the user clicks them. Option buttons and check boxes, as well as command buttons are typically thought of as buttons. Buttons may contain either text or images (icons) that may need to be localized.

The Combo Box Control Class

wpeE.jpg (1584 bytes)

Combo box controls consist of a selection field similar to an edit control plus a list box. The list box may be displayed at all times or may be dropped down when the user selects a "pop box" next to the selection field. A combo box may contain a list of items that may need to be localized.

Depending on the style of the combo box, the user can or cannot edit the contents of the selection field. If the list box is visible, typing characters into the selection box will cause the first entry that matches the characters typed to be highlighted. Conversely, selecting an item in the list box displays the selected text in the selection field. Combo box control styles are described below.

The Edit Control Class

wpeB.jpg (1870 bytes)

An edit control is a rectangular child window in which the user can enter text from the keyboard. The user selects the control, and gives it the input focus, by clicking the mouse inside it or pressing the TAB key. The user can enter text when the control displays a flashing insertion point. The mouse can be used to move the cursor and select characters to be replaced, or to position the cursor for inserting characters. The BACKSPACE key can be used to delete characters. If a program assigns a value to an edit box because the user has pressed a key or made a mouse click then this material may need to be localized.

The Listbox Control Class

wpeD.jpg (1522 bytes)

Listbox controls consist of a list of character strings. The control is used whenever an application needs to present a list of names, such as filenames, that the user can view and select. The user can select a string by pointing to the string with the mouse and clicking a mouse button. When a string is selected, it is highlighted and a notification message is passed to the parent window. A scroll bar can be used with a listbox control to scroll lists that are too long or too wide for the control window. Some of the list items in a listbox control may need to be localized.

The Scroll-Bar Control Class

wpe10.jpg (1263 bytes)

A scroll-bar control is a rectangle that contains a scroll thumb and has direction arrows at both ends. The scroll bar sends a notification message to its parent whenever the user clicks the mouse in the control. The parent is responsible for updating the thumb position, if necessary. Scroll-bar controls have the same appearance and function as the scroll bars used in ordinary windows. But unlike scroll bars, scroll-bar controls can be positioned anywhere within a window and used whenever needed to provide scrolling input for a window. Scroll bars are typically not localized.

The Static Control Class

wpeF.jpg (1085 bytes)

Static controls are simple text fields, boxes, and rectangles that can be used to label, box, or separate other controls. Static controls take no input and provide no output. Static control styles are described below. Most static controls need not be localized, with the EXCEPTION of  simple text fields (labels).

Accelerators

An accelerator is a keystroke defined by the application to give the user a quick way to perform a task.  Accelerators may need to be translated since they may be a mnemonic. Not all accelerators are translated, however, since some are windows-standard (CTRL-C, CTRL-V). Application specific accelerators may, however need to be translated

Hot Keys

Hot keys are used as shortcuts to activate menu commands and dialog box options. They may need to be translated, e.g., the hot key ALT + F would activate the File menu on the Window Menu Bar. In German, however,   a file is a Datei, so ALT + D would make more sense.

Dialog Boxes

Some objects that will need to be localized may be complex objects composed of other objects:

wpe9.jpg (23353 bytes)

This dialog (the Microsoft common dialog box) is actually composed of about fifteen different objects: (from top to bottom)

Many of the items above belong to particular object classes with which a localizer must be familiar.

Menus

A menu is a special input tool that enables a user to select commands and open submenus from a list of menu items. In the application below the Menu Items File, Tools and Help were defined with a menu editor. Each has a sub menu.  The & symbol indicates the key that can be used in conjunction with the ALT for a keyboard shortcut. Menu items almost always need to be translated.

wpe11.jpg (33103 bytes)


Resource Files Revisited