Accessing localization data via script

Hello,
my goal is to create a scroll view that would dynamically populate with elements representing the available languages based on the localization assets in the project.
I’ve been wondering if there’s any way to somehow access the data in specific localization files without having to assign them manually as attributes? Can the localization JSONs be expanded by additional data, like “language name”, in order to get “English” for the “en-US” locale, “Deutsch” for the “de-DE” locale etc.?
I’ve seen a property called assets in the I18n class, but it always returns an array of IDs, never the actual assets array.
Any clues?

Thanks in advance!

Assuming you have the text key, you can use getText or getPluralText to get the text from the key:

eg

var text = this.app.i18n.getText('someKey');

If you need it in a specific locale, pass the locale key as well.

eg

var text = this.app.i18n.getText('someKey', 'en-US');

Thanks for the fast answer! Of course getting values based on a key with getText is easy, but what if I added some additional value to the localization JSON?
Would it be possible for me to get somehow the name value through script in the example below?

    "header": {
        "version": 1
    },
    "data": [
        {
            "info": {
                "locale": "en-UK",
                "name": "English"
            },
            "messages": {
                [...]
            }
        }
    ]
}

No you wouldn’t. The localisation system wouldn’t parse and store that AFAIK.

You would be best storing that in your own JSON and mapping it to the locale code

Thanks for the great suggestion!