[SOLVED] Help regarding Localization

I just started looking into localization and i seem to have a hard time understanding the working of it from reading the documentation. If anyone can point me the right direction or an example would be helpful. Or to even translate a simple word from english to arabic and few other language is what i’m looking for. Thanks in advance

We have an example of English and Arabic switching here (Right to left language support | Learn PlayCanvas)

It requires a little bit of extra work due to Arabic being a Right to Left language.

2 Likes

So i’ve been trying different languages to translate and i wrote this

{
    "header": {
        "version": 1
    },
    "data": [
        {
            "info": {
                "locale": "en-US"
            },
            "messages": {
                "Start_eng": "Start Game",
                "key plural": [
                    "One key translation",
                    "Translation for {number} keys"
                ] 
            }
        },
        {
        "info": {
                "locale": "es-ES"
            },
            "messages": {
                "empezar juego": "comienzo",
                "key plural": [
                    "One key translation",
                    "Translation for {number} keys"
                ] 
            }
        }
    ]
 
}

but for some reason it’s not translating to spanish. the text only shows my key and not my value.

Have you ticked Localized on the text element?

Is the localization json file added in project settings?

If you have done both of these, can you share the project please?

The key for the text is not the same for each language:

Localisation works by having a key that the text element can lookup and find the text for that key in the current chosen language.

Ahh now i understand. Thanks!!. Is there a way i can test that?

https://playcanvas.com/editor/scene/1189331

This is the project i’m working on. Is there a way i can test both of them?

What do you mean by ‘test both of them’?

Like on my scene i have two buttons with text elements. is there a way i can show english and spanish text for my Start button?

Not at the same time, no.

Change the localisation file to:

{
    "header": {
        "version": 1
    },
    "data": [
        {
            "info": {
                "locale": "en-US"
            },
            "messages": {
                "Start": "Start"
            }
        },
        {
        "info": {
                "locale": "es-ES"
            },
            "messages": {
                "Start": "comienzo"
            }
        }
    ]
 

Now in the project settings, you can change the language to en-US or whatever you like:

Or during runtime, you can change the language by typing the follow in the console:

pc.Application.getApplication().i18n.locale = 'some locale code'

eg

ahh i understand clearly right now. Sorry for the stupid question though lol. Thanks @yaustar .