Skip to content
valioDOTch edited this page Mar 8, 2014 · 7 revisions

How to translate

Translating texts

For translation from English to another language

  • go to /code/FINAL/locales
  • create a copy of the file translation-en.json and name it after the 639-1 letter code of the language you want to translate to. For example if you want to do a translation to French (code: fr) then your new file should be called translation-fr.json
  • open the new file and translate all strings that are right to a colon (":"). Do not translate any string on the left side of colons or before brackets
  • save the translated file
  • check that you're translated file is valid JSON. http://jsonlint.com/ simplifies that (just do a copy-paste)
  • commit and create a pull request

If you want to test your translation you need to setup a local server (e.g. Apache or nginx) on your machine, put the scripts in the web document folder (usually named "www") and open the game on http://localhost as some of the assets won't load if the game is accessed via the file:// protocol in your browser.

Translating images

You just translate the text in the locales-file as described above. Thereafter you go to /code/ and execute $ php translate.php You need to have PHP-CLI (command line interface) installed for this. This php script is not intended to be part of the deployed webpage. It's a command line script, not one for a webserver.

What the script does: Crucial images were edited, so that they are not PNG, but SVG and the text therein is actually text (not a bitmap). This script can also assure that the correct font is used in the images. Measures so that the text should now overflow but is stretched are taken within the SVG itself. If you want to write "iEye" in the image, please use the String "°Eye" (or similar in translation) to create the small letter "i". As all the lower case letters where so far denoted as upper case letters in the Ostrich-Sans font, I avoided changing the lower case letter "i", but used the "°" char instead (might need changes later on, if we ever denote temparatures or so in the game). If you want to add spaces at the beginning or end of a string for an image, so that it is stretched a little bit less (it is stretched automatically) then use this char as a replacement for space "¬". This is called a logical OR and was one of the few chars which I assumed would never be used in the game. If you used normal spaces there instead of "¬" they will be trimmed and you will see no effect.

TL;DR: you execute a script named translate.php via command line; takes care of everything.

The font

In some cases it might be necessary to edit the Ostrich-Sans font. The standard Ostrich-Sans font supports only latin characters. That means that if you e.g. write Cyrillic letters, they will not be taken from the Ostrich font, but from another system font, because the Ostrich-Sans simply does not have those letters. However one could add them (which will take some time).

However what is more likely: someone wants to translate in a language that mainly consists of latin letters, but has special latin letters in it as well (such as "æ", "é" or similar). If you don't want to work around those letters with some special phonetic notation (e.g. in German one can write "ae" instead of "ä" if there's really no other option), you should edit Ostrich-Sans. Else it will take a character from a random system font which is guaranteed to look ugly in the end.

The Ostrich font resides in code/FINAL/fonts. On Linux FontForge is suggested for editing. After editing you have to generate the new woff and replace the old woff file. From there the rest can be done by a script.

Open your system terminal to call translate.php residing in code/. This time you call it like so $ php translate.php updateFont This will update the fonts in all template SVGs. There will be some notices, but there should be no errors (else cry for help). That means that to update the language files you have to call again $ php translate.php Sorry if that's bothersome; will change it somewhen

But if you don't know what any of the stuff above means don't worry. Just tell me which char you need to have added and I will take care of it.

Clone this wiki locally