17. Change language from scripts and visual scripting
On this page
The same language actions are available through the shared action system. Use the normal action node or action-list entry in visual scripting, then set its language fields just as in the GUI event example.
For scripts, keep the entry function supplied by the editor. The following snippets show the relevant calls; you do not need all four language versions in one project.
GDScript#
await SetGameLanguage({
"language": "fr", "persist": true
})
await ChangeVoiceLanguage({"language": "en"})
await ChangeSubtitleLanguage({"language": "fr"})This requests French game text, English speech and French movie subtitle cues. Set persist to
false when trying a temporary game-language change.
To refresh the example GUI sign after selecting the language:
await ChangeGUIElementProperty({
"guiId": "translation_hud",
"elementId": "workshop_sign",
"property": "assetId",
"value": "sign_en"
})The source asset ID stays the same. Its language mapping decides which file is loaded when the element rebuilds.
PCA Script#
function run()
SetGameLanguage({"language": "fr", "persist": true})
ChangeVoiceLanguage({"language": "auto"})
end