Load a specific line from a text file

Hello! Here’s what I need help with:

I’m trying to make a game with multiple languages and I’ve been wondering, is it possible to store a language in a single file? By that I mean to store the game’s phrases one per line.
Example:

Modify the text of XYZ → to the first/second/etc. line of given text file.

Extra notes:

Let’s say the english language file would look like this:
"
Start the game
Multiplayer
Quit the game
"

And the other language would be basically a translated version of it.
Here’s spanish just for an example purpose.

"
Empieza el juego
Multijugador
Salir del juego
"

2 Likes

I’d look at using a file in json format, one file for each language (easier than all languages in one file). Without using json, it’s easy to get one line out, which then screws up a lot of the game’s text.

Have the same key in each file, but the different language phrase for the values. You then read the json into a structure (GDevelop will do it automatically), and because the keys are the same no matter which language, you refer to the text by accessing the structure the same way for all languages.


For example, here are the English and Spanish language files :

image

image


And here are the events to load and access the values :


Which results in :

ChangeLanguage

5 Likes

Thank you very much! I think that’s exactly what I was looking for, I’m gonna try to implement that soon.