Why Automate Game Localization?
As a game developer, reaching a global audience of people who speak other languages can significantly boost your game’s visibility, player base, and overall success. Unfortunately, translating game content into multiple languages can easily be out of scope for solo devs, hobbyists, or indie studios. By combining the open source Godot game engine and the DeepL API, you can automate translations, localize your game’s UI and dialogue, and easily reach a much wider audience. In this blog post, we’ll explore how to set up an automated translation system within Godot itself. This is a basic workflow example that you’ll need to adapt for your own needs, use cases, and project setup, but we hope you can take some inspiration from it.Setting Up Your Translation Script
Godot Script Overview
Our Godot 4.3 script leverages the DeepL API to translate predefined game text into multiple languages. It outputs these translations in a CSV format compatible with Godot, ready for use in your game. Here’s a breakdown of the script, which is written in Godot’s built-in GDScript language. You can attach it to any kind of Godot node.1
Define Languages and Originals
First, specify the languages you want to translate into and the original texts:
2
Initialize Translation Process
When the script’s node is ready, it initializes the translation process automatically. If you expand this script for your own needs you may want to attach this functionality to a button event so it doesn’t run every time the script does.These functions set up the translation structure for each language and loop through our list of desired target languages to send the requests to the DeepL API:
3
Request Translations
For each original text, the script requests translations from the DeepL API. We’re passing the additional
context
for each string, as well as the prefer_less
formality option to maintain a lighthearted and casual tone for our game.4
Handle Translation Responses
Once the API responds, the script processes the translations:
5
Save Translations to CSV
Finally, the script saves translations in a CSV format that Godot can read natively:This will produce a
.csv
file with the following content: