-
Notifications
You must be signed in to change notification settings - Fork 0
Translations
If you're interested in participating in the translation of the game's text into your language of choice, now you can using our language control system.
Most of the text in the game can be translated more-or-less easily. Here are the three categories of text in our game:
Type | Translatability |
---|---|
Dialog | Can be translated by adding JSONs with modified text |
Core text | Can be translated by adding an entry into an object in code |
Graphical text | Can't be translated without redrawing sprites |
First off, if the language doesn't exist in our system yet, it needs to be added to the LANGUAGES object, given a readable name in languageToText() and given a toggle position for the language selection in toggleLanguage().
Once that is done, you can move on to translating the core text, which, for the time being, consists of the main menu and credits text. This can be done by adding an entry using the same shorthand that was used to define your language in the LANGUAGES object. This entry should be created as a duplicate of the 'fr' entry. Once that is done, you can start translating the necessary text in said entry. The objects are MenuText and CREDITS_TEXT.
After that a new sub-folder must be added to the dialog folder and must bare the same name as the shorthand that was used to define your language in the LANGUAGES object (i.e. English is 'en' and French is 'fr). This new folder must be created as a duplicate of the fr folder, since this is the base on which the game was built and optimized. You can now tranlate all of the names and text in the different json files. Note that you must only change the "name"
and "text"
fields of the json files, changing any other field will result in a runtime error.
Let's say that I want to translate the game in German, then I must proceed as follows:
- Add German as a new language:
//In player.js
export const LANGUAGES = {
FR: 'fr',
EN: 'en',
DE: 'de' //This line is new
};
//...
/**
* Toggles the current language stored in the player
*/
toggleLanguage() {
switch(this.language) {
case LANGUAGES.EN:
this.language = LANGUAGES.FR;
break;
case LANGUAGES.FR:
this.language = LANGUAGES.DE; //Changed EN to DE
break;
case LANGUAGES.DE:
this.language = LANGUAGES.EN; //Always loop back to EN
default:
break;
}
}
/**
* Converts a language into a readable form
*/
languageToText() {
switch(this.language) {
case LANGUAGES.EN:
return "English";
case LANGUAGES.FR:
return "Français";
case LANGUAGES.DE: //this is new
return "Deutsch"; //this is new
default:
return "";
}
}
- Translate the core text into German, by adding new
'de'
fields to the core text objects:
//In buildingScene.js
const MenuText = {
'en': {
Credits: "Credits",
NewGame: "New Game",
Continue: "Continue"
},
'fr': {
Credits: "À Propos",
NewGame: "Nouvelle Partie",
Continue: "Continuer"
},
//Add DE here, note that the inner fields (i.e. Credits, NewGame and Continue)
//Must always be exactly the same in every language
'de': {
Credits: "À Propos", //This works in swiss-german
NewGame: "Neues Spiel",
Continue: "Fortsetzen"
}
};
//...
//In endScene.js
const CREDITS_TEXT = {
'en': {
TEAM: `
<h4>Programming</h4>Andrew Dobis
<h4>Graphics</h4>Mathias Hängärtner
<h4>Story, Sound desing</h4>Saara Jones
<h4>Project Management</h4>Yannick Rochat, Paul Ronga
`,
REPO: `
...
`,
THANKS: `
...
`
},
'fr': {
TEAM: `
<h4>Programmation</h4>Andrew Dobis
<h4>Graphisme</h4>Mathias Hängärtner
<h4>Récit, Conception sonore</h4>Saara Jones
<h4>Gestion de projet</h4>Yannick Rochat, Paul Ronga
`,
REPO: `
...
`,
THANKS: `
...
`
},
//Add a new de field here
'de': {
TEAM: `
<h4>Programmierung</h4>Andrew Dobis
<h4>Grafik</h4>Mathias Hängärtner
<h4>Geschichte, Sound desing</h4>Saara Jones
<h4>Projektmanagement</h4>Yannick Rochat, Paul Ronga
`,
REPO: `
... //There's stuff to be translated here too
`,
THANKS: `
... //And here
`
}
};
- Finally translate the dialog to German by:
- Duplicating the
fr
folder and renaming it tode
. - Translating all of the
name
andtext
fields of every json file inside ofde
.
- Duplicating the
Once all of this is done don't forget to test out the game locally by running npm run-script dev
in the source folder and checking that the game never crashes during a play through in German, if it does it probably means that you changed a field that you weren't supposed to. If all of that works, you can happily open a PR
entitled "<language> Translation" and request a review from anyone in the organization.
Congratulations you've just contributed to making this game accessible to more people!