Changing the language in the game

Can someone help me make a system to change the language of the game?

Choose the language in the menu and throughout the game at all stages the subtitles appear in the language chosen in the menu.

please help me

Well, it really depends on your game implementation… Certainly you would need Python for this. As you can see in this video, I did a language system for this game.

The basic logic is to load the languages as dictionaries (see the language files here as example), get the current language from your options (maybe also a dictionary) and make all your in-game texts point to a specific key on the language dictionary using the current language as key.

For example, assuming you loaded the language dictionaries to globalDict["Languages"] and the game options to globalDict["Options"]:

from bge.logic import globalDict

# Get the current language set in options (example: "English")
curLang = globalDict["Options"]["Language"]

# Get the current language dictionary from the loaded languages
curLangDict = globalDict["Languages"][curLang]

# Set the text of current object to the specific 
textObj.text = curLangDict["LoadingShort"]

In the example above, if globalDict["Options"]["Language"] is "English", the text object would show Loading..., if globalDict["Options"]["Language"] is "Portuguese", the text object would show Carregando..., and so on.

But again, it depends on your game implementation and this is MY own way of doing it, probably there are other ways.

1 Like

My solution is very similar to Joels, except I create a ‘language manager’ class. That class has a function for getting the text for a given String key.

The benefit with that method is you can have fallbacks - if the key isn’t available in the chosen language, then I make it fallback to a default language instead.

1 Like

Well, without Python you’ll have a hard time making localization for your game.

(Tente manter as postagens no fórum em inglês, ou manda mensagem privada :wink:).

That’s a great approach! I’ll try this way next time. I thought about using the gettext standard before, but the JSON based approach seems a lot more straightforward to me.

1 Like

You should take a look at the Dead Cyborg projects, they have some great examples of dynamic language replacement based on menu preferences.

Send me please

You can download from this link:

1 Like

So sorry for the late reply… I saw your message and got sidetracked unfortunately with other stuff… Yes, @firefox.jco link is the one you are looking for, thanks firefox.jco!

1 Like

How can i emplement this in game?