Translations Containing Ampersands (&)
An Ampersand is the name of the character used to denote the conjunction word "And". Its use in captions within Workbench however, has a special effect on the other text in the caption in the following ways:
- Used to provide a "Hotkey" (Alt + another character) to a menu option, button or tab.
- Used as an escape character to denote the following character is a literal character (Used when special character like the ampersand is to be treated like a normal (literal) character rather than like a special character).
- Used as a literal character.
Examples of the three uses of an ampersand:
HOTKEYS
Three Hotkeys are pictured here as underlined characters, One on a button, and two on tabs. These Hotkeys provide keyboard access to the controls that otherwise would require a mouse to access them. Pressing Alt + C will Close the form, Alt + A will make the Admin Functions tab current and Alt + P will make the Control Parameters tab current.
The captions for these 3 controls are as follows:
- &Close
- &Admin Functions
- Control &Parameters
Notice that the Ampersand is placed immediately before (No spaces) the character used in the hotkey.
In this case the ampersand provides the underlining of the character in the displayed caption on the control as well as the Hotkey functionality.
ESCAPE CHARACTER
Escape characters are used to allow a special character to be treated literally, in the following example we want to display a caption that says 'Salt & Pepper'.
However if we put 'Salt & Pepper' into a caption we get 'Salt _Pepper'. This is because the ampersand has a special use – The Hotkey, as detailed above. So in effect we have a caption with a hotkey assigned to the second (Space) character between the word 'Salt' and the word 'Pepper'.
To overcome this we can supply an escape character in the form of a second ampersand in the caption, so to display 'Salt & Pepper' we actually supply the caption 'Salt && Pepper'. The escape character (first ampersand) is telling the application that the following special character (second ampersand) is actually to be treated as a literal character (normal ampersand).
LITERAL CHARACTER
The literal use of an ampersand is when we want the ampersand to be just that, and actual ampersand. In the escape character example above the second ampersand in the 'Salt && Pepper' caption is a literal ampersand (the first one being the escape character).