Game Development Reference
In-Depth Information
8.1T EXT L OCALIZATION
Text replacement is the most common localization strategy used, it means that all text used
in the game and all of its user interfaces will be replaced by the text translated to the lan-
guage of the target locale. As with film, some games may not have the resources to localize
audio, providing localized subtitles may be a less expensive alternative for in-game dialogs
and videos.
Any text fields that require localization should not contain the text that is to be translated,
instead it should use a unique identifier, a key. Not only is it far easier to match a key to text
in multiple languages than it would be to translate word for word, but this allows linguistic
and cultural references to be applied to make the game more appealing and relevant to the
target locale. Thisimplies that akeymayrepresent aword,aphrase,orevenablockoftext.
Withakeyandalocale,weareabletoquerythelocalization database forthetextthatneeds
to be displayed.
When designing a localization system, consider that you should only ever load or stream
in the data for the locale the game is currently running on. We don't need to keep a large
amount of localization data for each language in memory. When changing the locale, an in-
frequent operation usually done from the main menu; it is best to release the data for the
currentlocalefrommemoryandloadinthenewlocaledata,recreatingourlocalizationdata-
base.
The localization key should not be a string, as we want to avoid unnecessary and computa-
tionally expensive string comparisons. Instead, each key should be a unique identifier that
we can use to query from the database. In terms of the unique identifier, some game engines
will already provide a mechanism for identifying resources, this is perfectly fine to use as
it will be consistent with the rest of the game systems. That said, we can also implement a
more straightforward solution. Localized text isnotsomething that can change dynamically,
we can use an auto incrementing unsigned int as the key every time we add a string to the
database. The downside to using a numeric identifier fortext is that when we reference keys
we lose the context.
const std::wstring label = localization::get_string(20); // ID 20 maps to “Open Chest”
const std::wstring label = localization::get_string(“OpenChest”);
This situation is less of an issue when you have a game editor or tools that are able to build
or package the game data such that you may use a string comparison during development,
Search WWH ::




Custom Search