Game Development Reference
In-Depth Information
Localization
Although it may be acceptable for smaller games to support only one language
(usuallyEnglish),mostcommercialgamestypicallyneedtosupportmorethanone
language. Localization is the process of adding support for these additional lan-
guages. Because many menus and HUD elements have text, it's important to take
localization into account when designing user interface systems. Even if a game
does not need to be localized, it's a bad idea to have onscreen text hard-coded into
source files because it makes it more difficult for nonprogrammers to modify. But
if the game is to be localized, staying away from hard-coded text is particularly
critical.
The simplest solution to the text localization problem is to have an external file
that stores all of the text in the game. This external file could be in XML, JSON,
or the like (a more in-depth discussion of different file formats can be found in
the following chapter). This could then map to a simple dictionary that has a key
identifying the particular string. So whenever the code needs to display text on-
screen, it will request the text from the dictionary using the appropriate key. This
means that instead of having a button hard-coded to display the text “Cancel,” it
may instead query the dictionary for the string associated with “ui_cancel.” In this
scenario, supporting a new language might only require creating a different file to
populate the dictionary from. This style of approach is utilized by the tower de-
fense game example in Chapter 14 .
Unfortunately, supporting languages that use different character sets can complic-
ate the matter. The traditional ASCII character set (which is what's used by the
char type in most languages) can only support the English alphabet. There's no
support for accent marks, let alone any support for other writing systems such as
Arabic and simplified Chinese.
Search WWH ::




Custom Search