Share via


Localization Guideline for Your Code

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

When writing code, it might be useful to think about how your code will be localized into other languages. The following suggestions might help you increase efficiency and reduce costs by writing code with localization in mind.

  • **Use unique variable names   **If the same variable name is used for different variables, for example, if the sequence of the variables is hard coded, the word order in the translated sentence might be wrong because word order differs from language to language.
    Example code Better code
    Set created on %s at %s Set created on %1 at %2
    Backup of %s on %s at %s Backup of %1 on %2 at %3
    Printing %s of %s on %s Printing %1 of %2 on %3
  • **Use dynamic or maximum buffer sizes   **Length restrictions for strings are potential build breakers. For example, if a string goes into a boot sector of a fixed byte size and the assembly code grows, there is no space for a longer translated string, which could crash the application. This problem is not likely to occur if buffers are dynamic or make it possible for maximum buffer sizes.
  • **Avoid composite strings   **The strings shown in the following table cannot be localized unless the localizer knows what the type of object or item the variables stand for. Even then, localization might be difficult, because the value of the variable might require a different syntax; the article "the" has variations in another language (in German: "der, die, das, dem, den, des," the same as in English where you have "a" or "an"); the adjectives might change according to the gender of the word; or other factors. Using composite strings increases the chances of mistranslation. These localization problems can be eliminated by writing out each message as a separate string instead of using variables.
    Examples of composite strings
    Are you sure you want to delete the selected %s?
    %s drive letter or drive path for %s.
    Are you sure you want to delete %s's profile?
    Cannot %s to Removable, CD-ROM or unknown types of drives.
    A %s error has occurred %sing one of the %s sectors on this drive.
  • **Avoid strings that contain a preposition and a variable   **Strings that contain a preposition and a variable are difficult to localize because, in some languages, different prepositions are used in different contexts.
    Example code Better code
    At %s Time: %s
    At %s Date: %s
    At %s Location: %s
  • **Avoid using compounded variables   **In the following example, to translate the preposition "on" correctly, you might have to ask the developer what the variables stand for.
    Example String Explanation from developer
    %I:%M%p on %A, %B %d, %Y %A Full weekday name
      %B Full month name
      %d Day of month as decimal number (01 - 31)
      %I Hour in 12-hour format (01 - 12)
      %M Minute as decimal number (00 - 59)
      %p Current locale's A.M./P.M. indicator for 12-hour clock
      %Y Year with century, as decimal number
  • **Avoid dividing sentences across multiple strings   **When a sentence is broken up into several strings, the strings do not necessarily appear consecutively in the localizer's string table. It is very time-consuming to piece strings together to form a correct sentence. In addition, because translation is not a word-by-word matter but the sentence structures differ from language to language, there will not be a one-to-one match in the glossary, which in turn might cause erroneous automated translations.
    Example of divided sentences (to be translated from English to German)
    • "When this box is checked, Windows NT does not"
      "automatically display the user name of the last person"
      "to log on in the Authentication dialog box."
    Example of divided sentences (translated from English to German)
    • "Wenn dieses Kontrollkästchen aktiviert ist, zeigt"
      "Windows NT nicht automatisch den Namen des"
      "Benutzers an, der sich zuletzt in dem Dialogfeld"
      "Authentifizierung" angemeldet hat."
    Example of divided sentences (translated back literally from German to English)
    • "When this control box checked is, plays"
      "Windows NT not automatically the name of
      "the user, who him/herself last in the dialog box"
      "Authentication" logged has."

See Also

Localizing Your Application | Localization Guidelines for Your User Interface | Localization Guidelines for Language and Terminology | Localizing Your Access Runtime Application