Tip: Using GBC Language Cabinet With Larger Applications

Background

GBC Language Cabinet is my free CoronaSDK plug-in that helps simplify the addition of multi-language support in your games and applications. Using GBC Language Cabinet is very easy… define the languages you want to use, add the translation text, and then call a function to retrieve the appropriate text in a specific language.

For smaller games, it is very convenient to create a separate Lua module to create and add all the required text that you need within the game, but what about larger applications that have many scenes and/or a large amount of text? What about scenes that are only displayed one time? In these cases, one large Lua file will work, but it is possible to use multiple Lua files to help you manage the large amount of text needed for games such as this.

Modular Approach to Translation Text Managment

For example, translation files can be created per scene, or included in each scene’s create() method…

-- remove all text entries currently stored in GBC Language Cabinet
GBCLanguageCabinet.clearText()

-- load scene specific text
GBCLanguageCabinet.addLanguage("English", "en")
GBCLanguageCabinet.addLanguage("Deutsch", "de")
GBCLanguageCabinet.addLanguage("Español", "es")

GBCLanguageCabinet.addText("RedBall", {
    {"en", "That is a ##color## ##object##"},
    {"de", "Das ist eine ##color## ##object##"},
    {"es", "Esa es una ##object## ##color##"},
})

Notice that for each scene, you remove all previous text, add the language, and then add the text.  This ensures that only the scene specific text is available.  This keeps the memory footprint lower, and makes management of text easier.

In Closing

GBC Language Cabinet is flexible, so the best approach is really up to you. It depends on your game and how you would like to manage it. Using a modular approach allows you to manage translation text in cases where a large number of scenes or a large amount of text makes a single file solution difficult.

I am always interested in knowing who uses GBC Language Cabinet… show me your games! Also, if you have any suggestions for improvements, please let me know.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: