As we are nearing our first Steam release, we wanted to make a strong effort to localize our game in as many different languages as possible. This brought up an interesting problem involving workflow and tools that we’ve now solved and wanted to share. We wanted a solution that would allow: * Multiple translators to work on a shared document at the same time * Automated conversion from the spreadsheet to the XML files used by the game engine * Easy usage inside the game engine * Forward compatibility with ShiVa 2.0 and its ability to create in-engine add-ons in LUA
The solution I came up with is very simple and has 3 components to it. Only one of these components is specific to my favored game engine, the remaining components are generic and can be modified to suite any project.
The workflow of this solution looks like this:
Check out and make a copy of the spreadsheet template to get started on your own translations.
The format of the spreadsheet is important. If it changes, the parser also needs to change. How the spreadsheet works is fairly intuitive and is probably easier done than said.
This spreadsheet is automatically translating english to all other languages using the function:
GoogleTranslate( text, sourceLanguage, destinationLanguage)
Look at the formula bar for any translated cell and you can see that I’ve defaulted the source language to english while pulling the destination language from the language code field on the top row. We all know how good/bad auto-translation is, love it or hate it, you decide on the quality of your translations.
The parser is a small LUA script that lives in the csv-xml-i18n repo. The parser takes a CSV file as input. To generate a CSV file from Google Docs, select File -> Download As -> Comma-separated values.
If you don’t have LUA installed on your system, you’ll of course need that to run the code. You can then feed the parser your CSV file by passing the filename as the first argument:
lua csvToXml.lua test.csv
The result of running the script is that language files will be generated for each file and language defined. The naming convention is [filename]-[country code].xml.
Download my ShiVa AI to easily implement localization in your game.
The I18N AI has the following features to make ShiVa localization a breeze:
log.message ( I18N.getString ( "MenuScreen.title" ) -- prints "Awesome Game!" log.message ( I18N.getString ( "KeyBind.jump" ) ) -- prints "Jump" log.message ( I18N.getString ( "KeyBind.attack" ) ) -- prints "Attack"
The AI automatically loads the XML file matching the OS language. If your OS is set to french and you request a string from MenuScreen, it will first try to load MenuScreen-fr.xml. If it can’t find that file, it will fall back to MenuScreen-en.xml. The fallback language is english.
To use the AI and XML files in your project, follow these simple steps:
There is also a cleanup function that can be called <pre>I18N.cleanUp()</pre> that empties out the hash table used to store the XML file contents. Use it when you want to clean up strings that won’t be used anymore.
This system is simple and it works. Follow the rules and it will work for you too. If you use this system, please let me know in the comments!