Skip to content

Make a game with multiple languages

Rolpege edited this page Sep 13, 2010 · 1 revision

Hey!

I’m making a game in flixel (my first game in flixel and my third game ever. But the first sucks and the second is only a remake in AS3 and better. But I’m embarrassed of this two games, so I’ll say that this is my first game… Jeje.), and I’ll make it with various languages.

Here, I will post the way that I’m making it, so you can make it too.

First, we need a Glossary class. Here’s an example:

package co.cc.aberustudios.AsteroidBelt
{
	public final class Glossary
	{
		internal static const CATALAN:int = 0;
		internal static const ENGLISH:int = 1;
		internal static const JAPANESE:int = 2;
		internal static const FRENCH:int = 3;
		internal static const SPANISH:int = 4;
		
		internal static var currentLanguage:int;
		
		internal static const PLAY:Array = ["Jugar", "Play", "遊", "Jouer", "Jugar"];
		internal static const HELP:Array = ["Ajuda", "Help", "手伝い", "Assistance", "Ayuda"];
		internal static const ACHIEVEMENTS:Array = ["Èxits", "Achievements", "達成", "Réussites", "Logros"];
		internal static const LEVELEDITOR:Array = ["Editor de nivells", "Level editor", "レベルエディタ", "Éditeur de niveau", "Editor de niveles"];
		internal static const CREDITS:Array = ["Crèdits", "Credits", "クレジット", "Crédits", "Créditos"];
		internal static const SELECTLANGUAGE:Array = ["Selecciona l'idioma", "Select language", "言語を選ぶ", "Choisir la langue", "Escoge el idioma"];
	}
}

Now, when we set the text to a button, the only thing that we do have to do is to call the array with the word, and put there the current language. For example:

Glossary.PLAY[Glossary.currentLanguage];

For the text for play button.

And, in the select language screen, to switch language we do this:

Glossary.currentLanguage = Glossary.ENGLISH

If we want English. The same with other languages.

EXTRA: There are languages, such as Japanese, that have special characters. You can change the font with this conditional

Code:

if (Glossary.currentLanguage == Glossary.JAPANESE) …

I hope this help!