Skip to content
MarkL edited this page Feb 27, 2014 · 8 revisions

Description of how to implement and use different text for different languages

Localisation in CorsixTH

We have two types of languages in the game:

The first one is languages that are already in the original game. Most of the translation work has already been done, but over the course of development we have added new text or changed existing text (due to technical reasons or features). For example the French language is in the original game, but we have around 750 new lines on top of the original.

We also have languages that weren't in the original game - Russian and Dutch for example. These are 100% new to the game and at present stand at around 2,500 lines of text.

List of our languages

(CorsixTH 0.11+)

Original languages (from original game)

English French (francais) Spanish (castellano) German (deutsch) Swedish (svenska) Italian (italiano)

New languages

Chinese (simplified)
Chinese (traditional) Czech
Dutch (nederlands) Finnish (suomi)
Norwegian (norsk) Polish Portuguese Russian Danish
Brazilian Portuguese
Hungarian

Not yet implemented (But in progress)

Romanian
Arabic Greek NEW!

Status

The status of every translation can be seen in the translation-forum: [A more detailed overview can be found in the language topic of each language, found here: http://forums.corsixth.com/index.php/board,15.0.html (Additionally, translation requests will be posted there)

Official translators will also receive an e-mail if there are translation requests. (If you´d like to contribute, please contact us)

Working on an existing language

If you´d like to help out with our current translations, please get in touch with our Localisation Management team. The easiest way to do this is through our forum [via PM (Bluebaerry and/or SimplyRyan). Please send us a message with your language as subject and your e-mail address. Once you have done this, you will become one of our official translators.

But First, one Important thing: If there is work to do, we will announce it via e-mail and in the forum (So you might want to keep an eye on the post of your language here: http://forums.corsixth.com/index.php/board,11.0.html). Please let us know what you do, when you do, so we can keep track of the translations process and the status of all languages.

Depending on how technical you are, there are then two ways to get started:

A The first way is to simply get stuck in, and start editing files. (More information can be found below or in our translation guide in the forum [Once you are comfortable, we can provide access to the google code site and let you submit your files/updates directly to the trunk.

B The second is where we provide you a little assistance. Providing the text in a generic format via e-mail, which you can easily work on. When you´re done, just send the edited file back to us and we will add it to the game ourselves.

Finding Translatable Strings

To see what strings can be translated, consult the existing language files http://code.google.com/p/corsix-th/source/browse/trunk/CorsixTH/Lua/languages/) and/or do a string dump (Press Ctrl + Shift + D or turn on the debug option in config.txt (see Configuration File), then menu bar -> debug -> dump strings). This should create several text files in the directory your config file and your savegames are also located in.

  • debug-strings-orig.txt: Contains strings of the legacy system
  • debug-strings-new-lines.txt: Contains strings of the new string system line-by-line
  • debug-strings-new-grouped.txt: Contains strings of the new string system in a grouped manner (Can be used as a template for new languages)
  • debug-strings-diff.txt: Contains strings that are missing and strings that are superfluous in the currently selected language. (The strings we need translated)

Implementing a new language

If you'd like to see CorsixTH presented in a language not currently implemented, then you are able to implement a new language. The only restriction is that if you need to use characters / symbols / glyphs which are not present in the original Theme Hospital fonts, glyphs that are used in English, French, German, Italian, Spanish, and/or Swedish, you will also need a font file when playing the game.

Header

To start creating your language, you should create a file called language_name.lua in the CorsixTH\Lua\languages directory. Then open said file in a text editor, and add the following standard header:

--[[ Copyright (c) 2014 <your name>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. --]]

Font("unicode")
Language("ownname", "name", "code1", "code2")
Inherit("existing_language")
Encoding(utf8)

Where "ownname" is the name of your language in your language itself, "name" is the name of your language in English, and "code1" etc. are the ISO 639 codes for your language. Note that the "ownname" is used for display purposes, so make sure it is written in proper case. For the other entries, the case does not matter. The Font and Encoding directives are used to tell the game that this language needs additional glyphs. Make sure that the file itself is utf8 encoded. To make the process of adding a new language easier, you should include an Inherit line so that any strings which you haven't translated yet are still displayed (albeit in the inherited language). Note that until custom translatable sounds are implemented, the inherited language will also provide the receptionist announcements. For example, the last two lines of the header might look like:

Language("Deutsch", "German", "de", "ger", "deu")
Inherit("English")

Translations

The remainder of the file lists all of the translations for the language, in the format a.b.c.d = "translation";. To avoid repetition, translations can be grouped together inside curly braces, making the following two code blocks equivalent:

menu.file     = "Ye Olde File Menu";
menu.options  = "Ye Olde Configuration";
menu.display  = "Tweak ye olde eyes";
menu.charts   = "Avast - Charts!";
menu.debug    = "Arr! Debugging!";
menu = {
  file     = "Ye Olde File Menu";
  options  = "Ye Olde Configuration";
  display  = "Tweak ye olde eyes";
  charts   = "Avast - Charts!";
  debug    = "Arr! Debugging!";
}

Technical note: The normal rules of Lua assignment do not apply, so the above two blocks really are equivalent, and the second block does not erase any other keys present in menu.

Adding new strings

As features are added which were not in the original game, or things are implemented slightly differently, it can become necessary to display text to the player which was not present in the original game.

In this case, new translatable strings should be added. Rather than just writing "New text" in the Lua code, _S.section.whatever.new_text should be written, and then section.whatever.new_text = "New text" should be added to the English language file, along with any other language files which the author is familiar with. Note that new strings should always be provided in at least English, as all other languages (directly or indirectly) inherit from it for strings which are not yet translated into that other language.

Legacy System and New System

Prior to r373, the original Theme Hospital string tables are used to provide text in different languages. In this system, each string was identified by two numbers (for example, (44, 107) identified the string describing the cause of broken wind), and Lua code referenced strings using the global _S function (for example, _S(44, 107) returned the string describing the cause of broken wind in the current language). There were several issues with this system:

  1. String tables were binary files, making them hard to inspect or edit.
  2. New strings could not be added, as that would involve redistributing original data files (albeit modified original files).
  3. The two-number identifiers were fairly opaque and meaningless

Hence, starting from r373 (having been discussed in issue 139), a new system is in place for translatable text. In this system, each string is identified by one or more name parts (for example, diseases.broken_wind.cause identifies the string describing the cause of broken wind, and menu_options_volume(identifies the string for 60% volume in the options menu). Lua code references strings under the global _S **table** (for example, _S.diseases.broken_wind.cause gives the string describing the cause of broken wind in the current language). Strings can still originate from the original game string tables, but they can be changed, be given names, or be augmented by text (rather than binary) files.

Strings from the original game are given names by the CorsixTH\Lua\languages\original_strings.lua file. At the current time, not all strings have been given names, so a temporary mechanism is in place to allow existing Lua code to still use the deprecated _S(x, y) method for accessing strings.

Technical note: The values returned by indexing or calling _S are not actually strings, but are infact clever userdata which look a lot like strings. Most of the time this shouldn't be an issue, but there are a few gotchas: string methods should be called using the method syntax (s:gsub(...) rather than string.gsub(s, ...)), equality testing between two strings cannot be done in the normal manner (for technical reasons), and the byte, find, gmatch, match , and sub methods are unavailable.

Additional Information

Localisation Management Team

Suse(Forum: Bluebaerry) - Localisation Management (Organisation) Ryan(Forum: SimplyRyan) - Technical Localisation Management (Implementation & Support)

FAQ

Q: I want to help but I'm quite new to the game A: No problem, head over to this forum post which has lots of useful information - http://forums.corsixth.com/index.php/topic,3446.0.html

Q: Do I need any special tools to help translate? A: Not right now, you can use any text editor that supports UTF-8. But we recommend Notepad++.

Q: I want to create a new language that you don’t already have A: Wonderful! Firstly it's a huge undertaking as we have thousands and thousands of lines of text, so ideally we would like a few people to work on a new language, but don’t let the amount of text worry you - contact us and let's talk!

Clone this wiki locally