[SOLVED] Multi language menu

Hello,
I would like to manage a multi language game.
The idea is to automatically reconosize the language in base of the device o.s. or browser (en, fr,it,…)and read the corresponding JSON file with all texts.
Then put the JSON in a global structured variable and USA the text.
Is it possible to do it with gdevelop?
Thanks,
J

Hi!

  1. The standard functions for working with Json files, which are located in the Filesystem section, work only when exporting to a desktop application. In the browser and on mobile devices, these functions do not work.
  2. There is an extension to detect the current language.
  3. I have not seen any automatic mechanisms for localization, so you most likely need to do everything yourself: define the necessary keys (variables), fill in the necessary values ​​at the start of the scene (depending on the language) and assign values ​​to objects.

I would advise you to create an extension for a project, in which a map (array, json-format) with a key and a value in the appropriate language is in JavaScript. And, if necessary, refer to this function and get the value by key.

1 Like

Thanks. The extension is perfect !!!
My idea was to give to the translator a file and load it directly without copy and paste each word into gdevelop GUI. I think itsnt possible now.
Thanks and regards,
J

1 Like

You don’t need to insert every word. If you create your own extension, then nothing prevents you from the received JSON-structure (which you wanted to put in a separate file), just insert it as a variable value into the JavaScript code. And use this variable to get the value. In fact, your file will be just inside the extension and you can simply copy it.

1 Like

Forgive me but my bad english with my poor knowledge of javascript I struggle to understand you.

I need to create a javascript that reads a json and save it in a game strimg variable. So transfer it to a facility automatically?
However, it is not clear where to save the file (for each type of compilation).

Or I have to write the JSON directly into javascript. insert the javascript in an extension. In this way it is possible to open it in a simple way.

An example is included with GDevelop called multi language menu:
https://editor.gdevelop-app.com/?project=example://multi-language-menu

The example is using structure variables to store all the text for each language which is probably not ideal if you have lots of text in your game because you keep all the text loaded in memory. So it is probably not the best choice for adventure games. But if you have only few text, mostly the menus and GUI, it is relatively simple way to go about it.

Or I have to write the JSON directly into javascript. insert the javascript in an extension. In this way it is possible to open it in a simple way.

Yes, that’s what I meant. Example: Working with JSON - Learn web development | MDN

Also take advantage of @ddabrahim advice.

Sorry, English is not my first language and I use a translator a lot.

Update: If there is a lot of text and it is consistent, then you can also try using the extension with the dialog tree. As a replica, you can indicate just the necessary text, and branches of their translations into another language. But here you have to experiment, how convenient it is. http://wiki.compilgames.net/doku.php/gdevelop5/all-features/dialogue-tree

1 Like

Thanks,
it works well.
Here the code: GitHub - jumpingjh/MultiLanguage: Manag Multi languge in GDevelop projects. Thanks to E1e5en

1 Like