Help With Multi Language System

Hi , i come here for ask for help!!

If anyone can give me some idea how i put multi language system ingame!!!

I think the correct is have some file texts with rows with language!
And with some script import that file !! But i just dont know how make that !

Can someone give me any idea?

Hello, yes you need to have a language variable that the player can change, so you need to have a string for each dialogue, example $quest1, based on the language variable the string will get the data from english archive(or text file) or from others language database or text files…
I suggest you to call the variables based on where they are used example $shop_welcome01 or $inn_foodlist01
You will also have some words that will be used in different kind of situation so u can set a $talk_goodbye or $talk_you variables that can be used in different part of game…that’s how i solved the problem :smiley:

The easiest way is probably to create a json file for each language you want. In your game you can load and use the json file for the language you require.

Where ever you use strings in your game/ui, make sure you look up the string rather than hard code it.

For example:

in file: fr.json

{
    "Start Game": "Commencez jeu",
    "Pause": "Pause"
}

Define a script like:

loadLang: function (lang) {
    // find the json asset that has your language
    var asset = app.assets.find(lang, "json");
    // when the asset is loaded store the data into variable `this.data`
    asset.ready(function (asset) {
        this.data = asset.resource;
    }, this);
    // load the asset if it isn't already
    app.assets.load(asset);
},
getText: function (src) {
    return this.data[src];
}

Make sure to assign a default value to language variable or you will be without a reference when a player start the game or make a choice at the start if u insert the player name

Here’s how I did it for a game with English and French text:

https://playcanvas.com/editor/code/63/hud.js

Notice how I’m using the browser’s currently selected language to chose which strings I use:

var getLang = function () {
    var lang = 'en';
    if (navigator.language) {
        if (navigator.language.substring(0, 2) === 'fr') {
            lang = 'fr';
        }
    }
    return lang;
}

thanks a lot , thats resolve the problem… rs

i am using the tanx game , but i add some new functions like chat ingame , chat just for the team , rankings , login syste , create account with mysql , room list , user can create new room , when chat ingame appear baloon , and now i am putting multi language!!

again tanks a lot

Where can i see your project it will help solve my problems too with mysql.

i am solve some problems , but later i wiil publish

Ok…i know how hard is to get rid of problems at the beginning…i’m getting discuraged lol