Godot Game Localization

Uncategorized

I wanted to give myself a challenge, so I decided to teach myself how to localize games in Godot. Godot is a free, open-source game engine, and currently (3.0+), it uses three different languages: GDScript (its own language that is dynamically scripted, similar to Python), C#, and JSON. A single game can have all three.

On the surface, Godot localization is simple. It is integrated into the editor, and translation files are automatically generated from CSV or .mo/.po files. You can easily assign fonts, images, or sounds to certain languages by remapping them in your Project Settings. It has a built-in translation method (tr()). It even has a TranslationServer class to manage translations. But there are many different ways text can end up on the screen, and each of these requires a slightly different approach.

In the game I chose to localize into Russian, I encountered two of the three languages (GDScript and JSON), and four different localization strategies were required. The game I ended up experimenting with is Hijinx, which was developed by John Gabriel. Gabriel had posted his games on a Reddit post asking for people to offer up their games for people to use to help them learn the engine, and I chose it because it had a lot of text compared to other Godot games, which I figured would mean that there would be a wide variety of localization problems — and I was right.

Different Localization Scenarios

Static UI Text

The way Godot primarily works is that there are “labels” in the game, and you create a CSV in Excel with “keys” for the labels and the translations in all your languages (or .mo/.po files, if you want to take that route). Some of these labels are simply in the UI, and you can change the label directly in the .tscn (scene) file using the scene editor, in the 2D or 3D space. Then the corresponding key for the language the game is running in will be found during run time. There is no need to wrap strings or change anything in code. An example of this would be the copyright line on the main menu screen.

Copyright editor view
Changing copyright text in the UI and the label editor.
Copyright text in the game
The copyright text in the game.

Static UI Text Requiring Player Interaction

Another variation on this theme is text in the UI that while it can be changed directly in the 2D/3D scene editor, it also has to be changed in the code itself in the .gd file that corresponds to the .tscn file (you can access the script by clicking on the scroll icon next to the name of the scene file in the scene menu, although sometimes you just have to search around for the necessary code), because the player will interact with it in some way (clicking on it, pressing the “return” key, etc.). An example of this would be any of the menus in the game. The label text in the game, which would just be a hard-coded string in a game that has not been internationalized, is simply changed to the key you have designated for the label.

Menu item in editor
Changing a menu item in the UI.
The corresponding script
The corresponding script.
In the game
In the game.

Dynamically Changing Text in the UI

Sometimes, you will come across text that you can see in the Scene Editor, but you cannot change the label there – the text is determined by what is happening on the screen. I encountered this while localizing the map UI. The name of the level, for instance, displays at the bottom, depending on what location on the map your character is standing on. For this, I had to locate where the text is in the script files and change the hard-coded strings to the keys there.

Level name in editor
The level name goes here… but it cannot be changed from here.
Level names in code
The level names have to be changed in the code.
Localized level name
“Proving Grounds” successfully localized to “Полигон.”

Dynamically Changing Text in a .tscn File

There can also be text that does not appear in the scene editor (the designated location will be visible, but no text). In this game, there are tips that show to the user before they play a level. The hard-coded strings had to be changed to keys in the .tscn file itself. Interestingly, the concatenated string required wrapping using tr(), while the others did not.

Tips in .tscn
Hard-coded strings are changed to labels corresponding to keys.
TIP_TEXT (L) and TIPONE_TEXT (R) in Russian in the game.

Dynamically Changing Text in a JSON File

The last method I had to use to localize text successfully was one that required me to draw upon my past knowledge of Python, JavaScript, etc., and apply it to GDScript. There is an interactive conversation you have with a turtle in the tutorial level, where he explains the plot of the game to you, and this conversation is pulled in and read from a JSON file. Wrapping strings and using keys did not work here. Instead, I translated the file itself in Visual Studio Code, and used Godot’s TranslationServer feature to bring it in. In the .tscn where the file is pulled in, I used get_locale(), a TranslationServer method, and stored that in a global variable, in case I had to use it later, although I know this is not a best practice. Once I had my current locale stored in a variable, I added an if/else statement to the load_conversation function, telling it to pull in the translated file if the locale was “ru,” and otherwise to pull in the English file (if I were localizing into more languages, I would add elif statements). This worked, and now my turtle speaks (Google-translated) Russian. This is the code:

var loc = TranslationServer.get_locale()

func load_conversation():
	var file = File.new()
	if loc == "ru" :
		file.open("res://json/conversations_ru.tscn", file.READ)
	else:
		file.open("res://json/conversations.tscn", file.READ)
	var contents = parse_json(file.get_as_text())
	conversation = contents["conversations"][conversation_slug]
	file.close()
Visual Studio Code
Translated text in Visual Studio Code.
The turtle
The turtle in action.

Takeaways

Hijinx is a complex game, and one of the challenges of Godot localization that I found is that while there is so much built into Godot for localization, there is not a lot of information available on it. I ended up having to download Godot’s demo games and trying localize those, but once it clicked, then it did become as easy as the documentation promised. And I hope that this blog post will help fill in some of the gaps for the next person who decides to localize a Godot game!

Additional Resources

Subtitling Groucho: A Case Study

Spring 2019

Introduction

While deciding on a subtitling project to hone my skills, my mind immediately went to a particular 1959 episode of What’s My Line?, a live panel game show that ran from 1950–1967. 60 years on, this episode has managed to amass over one million views on YouTube, due to the antics on one Groucho Marx.

The Show

What’s My Line? is generally a genteel, sophisticated show, especially for the game show genre. The regular panelists are Bennett Cerf, founder of Random House and publisher of Joyce, Faulkner, and many other 20th-century literary giants; Dorothy Kilgallen, a journalist and radio personality known for her columns and her coverage of the Sam Sheppard case; and Arlene Francis, a Broadway actress and fixture of the first couple of decades of television. It is moderated by John Charles Daly, a news anchor for CBS. The game usually proceeds with the panelists, accompanied by a fourth panel member, asking yes-or-no questions of a guest in order to figure out their occupation, which the audience has seen and they have not. Proceedings are normally quite formal and dignified, with perhaps a few laughs garnered when someone asks a particularly amusing question in light of the contestant’s occupation. There is also always a mystery celebrity guest, who disguises their identity, which the panel then has to guess.

The Episode

But in this episode, normal gameplay is out the window, because Groucho Marx comes on, in his first of two appearances on the show. He brings with him his comedic sensibilities, honed in vaudeville, and a complete disregard for the rules of the game. Everything and everyone is thrown off-kilter, and this creates every potential issue for subtitling that you could think of. There are multiple people speaking at once, interruptions, forced narrative, dialogue that is both overly short and overly long to fit in a subtitle according to Netflix’s guidelines, and even the use of a foreign language. This last issue, however, was not Groucho’s doing—this episode’s live broadcast happened to have taken place the week Khrushchev visited the United States, and there are numerous topical references throughout the episode, including celebrity mystery guest Claudette Colbert deciding to disguise her identity by answering question with “da” or “nyet.”

These issues also have to be dealt with in different ways, depending on the language. Certain things require subtitles in some languages, but not others. For this project, I have chosen Russian, but I have considered the ways that these issues may be handled differently in other languages.

Subtitling Issues

Foreign Dialogue

According to Netflix’s guidelines, whether or not foreign dialogue is translated depends on the context. Is the viewer meant to understand? Was it translated in the original? In this case, although if you watch the episode you can see that Dorothy Kilgallen struggled, we are supposed to understand, and therefore, it should be subtitled. But it is not necessary to translate “da” and “nyet” for a Russian audience. For any other language, however, we would have to follow Netflix’s guidelines for text in a foreign language. In this case, it would be best to simply translate into “yes” and “no” in the target language, although for English closed captions, “da” and “nyet” would be best. If we translate “da” and “nyet,” we would also indicate that Colbert is speaking in Russian in the subtitle as per the guidelines.

Onscreen Text

Onscreen text is a consistent presence in this show. The contestants write their name on a chalkboard, their occupations (or name, in the case of the mystery guest) is flashed on the screen, and there are placards in front of each panelist with their name on it. In the case of on-screen text it should be subtitled only when essential. This is known as a “forced narrative” subtitle. Subtitling the name placards would be distracting, and would not really add to the viewer’s understanding, since the panelists are frequently referred to by name. The professions are obviously necessary for the viewer’s understanding of the game, and should be translated in each case. In addition, those involved in the game generally stay quiet while this text is on screen, because the audience at home is meant to be reading the text (although there may be laughter from the audience if the occupation is unexpected or amusing).

Names, however, are another story. Daly always says the contestant’s name, so there is no need to subtitle the chalkboard. As mentioned above, the mystery guest’s name is also shown in additional onscreen text, just like the occupations of the other contestants. A subtitle for this text would not be required in a language that uses the Latin alphabet, since the name would be written the same way. But for Russian or another language that does not use the Latin alphabet, it should be subtitled to ensure that the viewer understands who this person is, as in the clip below. Timing is important here, because here, at least, conversation begins before the name has left the screen. I also had to move the dialogue in the subtitle after the forced narrative style to the top position, because the onscreen text remained and it interfered with the subtitle.

Multiple Speakers, Interruptions, Inaudible Dialogue

The game was filmed live, and conversations occur naturally. There is no script. In addition, in this episode, we have Groucho interrupting and making side comments to the other panelists throughout the show. The latter also sometimes requires judgment, because the side conversations are not always easy for the viewer to hear. The standard I used while transcribing was that if I could understand it, it should be subtitled. The various interruptions and people talking over one another require some finesse when deciding where certain dialogue should go, especially since Netflix’s guidelines require no more than two lines per subtitle.

Dialogue That Is Too Short or Too Long

The “yes” and “no” answers of the game tend to be short, especially during Colbert’s segment, where she is not offering any additional commentary, since she is answering in Russian, so her answers are short. Generally, this can be solved by combining it with the subtitle for the next line, especially when the next person speaks immediately after her. You can see some examples of combining short dialogue with long in the video above. With someone like Daly, length can be extremely challenging, since he tends to be verbose, sometimes to the point of exaggeration.

An example of a Daly response:

I think if you’re going to pursue this line of questioning, we must first elicit, or at least find the term of reference in which the question is asking — if you are speaking of physical contact, or the normal social contact of the conduct of business, we would be able to help you.

John Charles Daly to Dorothy Kilgallen

This, on its own, is a challenge to subtitle, especially in combination with other people participating in the conversation. When you have to make cuts in order to fit guidelines, part of the viewing experience is lost. When I spotted the dialogue, it ended up being:

Subtitle 1: If you’re going to pursue this line, we must first elicit,
Subtitle 2: or find the term of reference in which the question is asking,
Subtitle 3: if you are speaking of physical contact, or the normal contact of business,
Subtitle 4: we would be able to help you.

This episode provides many challenges for the subtitler, even without getting into the challenges of actually translating the dialogue, since I used machine translation. Translating some of the jokes and an unintentional double entendre in the second segment of the show, featuring poor, very rattled Dorothy Kilgallen, would require an entire second essay in order to discuss how a subtitle translator would handle them. As it was, this project could truly serve as a crash course in addressing a range of issues that pop up during the subtitling process.

Special thanks to W. Gary Wetstein of the What’s My Line? YouTube Channel for providing me with his original file of the episode.