Visual Basic Concepts
When you're developing an application that will be localized — whether you're programming with Visual Basic or another tool — you must take into account differences between languages. You should identify the strings that need to be localized, allow for strings to grow, and avoid the pitfalls of string concatenation.
The localization model presented in "Designing International Software" introduced the concepts of data block and code block. When building the resource files containing all the localizable strings, it is important to include only the strings that need to be localized. Any item that does not need to be partially or entirely localized can be hard-coded. Conversely, it is also fundamental to make sure all the resources that need to be localized are actually present in these resource files.
If you are declaring a buffer size based on the expected length of a string or word, make sure this buffer can accommodate larger words and strings. See "Designing an International-Aware User Interface" for average growth rates of translated strings. The buffer size you declare in your Visual Basic code must account for this increase.
Consider the following example. Your Visual Basic declares a 2-byte buffer size for the word "OK." In Spanish, however, the same word is translated as "Aceptar," which would cause your program to overflow. Identical considerations apply for double-byte characters. Refer to "Issues Specific to the Double-Byte Character Set (DBCS)" later in this chapter for more information about DBCS.
When you try to reduce the size of a string, one possible approach is string concatenation. This method allows you to use the same resource in several strings. However, there are some dangers when using this approach. Consider the following example:
English | French |
String1: one after the other | String1: un après l'autre |
String2: The controls will be deleted. | String2: Les contrôles seront supprimés. |
String3: The forms will be deleted. | String3: Les feuilles seront supprimées. |
Taken separately, String1, String2, and String3 can be easily localized. If your code performs String2 + String1 or String3 + String1, the resulting English string would look fine. The localized strings, however, are likely to be wrong. In the French column, for instance, String3 + String1 would be wrong because in French grammar, forms (feuilles) is a feminine word, thus String1 should be "une après l'autre" and not "un après l'autre." The same situation will be true in many other foreign languages. The only way to avoid this is to keep String2 and String1, and String3 and String1, together in the resource file.
In the above example, the order of the words that make up the sentence is the same in English and in French. However, the order is generally not the same in these two languages, or many other foreign languages. (For example, in both German and Japanese the verb generally appears at the end of the sentence.) The following example illustrates this situation:
English | French |
String1: DLL | String1: DLL |
String2: Missing Data Access | String2: Accès aux données manquante |
String3: Missing OLE | String3: OLE manquante |
If your code performs String2 + String1 and String3 + String1, localized versions will be broken because the order of the two strings produces a message that does not make any sense. One possible solution is to simply add String1 to String2 and String3 directly in the resource file and remove String1.
Another possible solution is presented in the following table:
English | French |
String2: Missing Data Access '|1' | String2: '|1' d'accès aux données manquant |
String3: Missing OLE '|1' | String3: '|1' OLE manquant |
In this case, the localizer can identify '|1' as a placeholder and make the necessary changes in the resource file to reflect the appropriate way to build a sentence for the localized language.
Finally, it is also important to know that words or sentences that appear identical in English may need to be translated into different words or sentences when localized. Consider the following example:
English | French |
String1: Setup program | String1: Programme d'installation |
String2: String1 did not complete successfully. | String2: String1 a échoué. |
In the English version, String1 is used as the setup program banner. It is also used as part of an error message in String2. In the French version, String1 worked perfectly as the stand-alone banner string. However, it needed to become "Le programme d'installation" to be used with String2.