Automating Indie Game Localization with the DeepL API and Godot
Efficiently translate content for a global audience and widen your game's reach
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.
Step 1: Define Languages and Originals
First, specify the languages you want to translate into and the original texts:
Step 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:
Step 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.
Step 4: Handle Translation Responses
Once the API responds, the script processes the translations:
Step 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:
Wrapping Up
As you expand your game, consider developing a more sophisticated system to handle larger amounts of content. You could implement batch processing, caching of existing translations, a Godot-based UI for entering and editing original content, advanced error handling, and dynamic language selection.
This is just a quick example of how you can incorporate the DeepL API into a game project to enable effortless translation of your game's dialogue and other text content, allowing even solo developers access to an efficient and scaleable localization process that will enable their projects to reach players all over the world.
Last updated