4 min read

Dan's DevLog - June 2023

Screenshot of the Thai version of Luck be a Landlord

Hey everyone! Today we're gonna talk about the challenges of adding new languages to Luck be a Landlord. Also, don't worry, the mobile port is very close to completion, I was just excited to talk about this. Let's dive into it!

New Languages

Adding a new language to Luck be a Landlord is a multi-step process. First, all the words/sentences, AKA strings, are translated by a member of the localization team. After that, I can't just drag and drop the localization file into Godot without any extra effort (although Godot does make it a lot easier, I love the Godot Engine).

There are lots of gotchas that can appear when I implement the localization team's hard work. For example, elements of the UI need to be custom-scaled depending on how long the strings are. This happens a lot in the German localization at lower resolutions.

The "Reset to Default" button or "Auf Standardeinstellungen zurücksetzen" button has to be scaled down since it's too wide for the screen.
The "Reset to Default" button or "Auf Standardeinstellungen zurücksetzen" button has to be scaled down since it's too wide for the screen.

There are also subtle differences within certain languages that aren't compatible with solutions I would normally implement for English strings. Let me explain:

Many games hard-code where their line breaks are, like how in a visual novel, a line of text that looks like this...

Text file with the string: "Thanks to you, I am saddled\nwith unecessary... feelings."
The "\n" character is what decides where the line will end and where a new line will begin.

...will display like this:

Screenshot of Phoenix Wright: Ace Attorney with the text "Text file with the string: "Thanks to you, I am saddled with unnecessary... feelings." but with a line break in-between the words "saddled" and "with."
Happy Pride, y'all

Did you notice the line break? Normally one might think to manually add the "\n" characters, AKA newline characters, to strings so that the text won't go outside of the UI elements it's contained in. Unfortunately, in Luck be a Landlord, the text can appear in differently sized UI elements depending on the game's resolution setting.

The solution was to effectively have the engine run a test on every character in the string and see if the character is "out of bounds" of the parent UI element. If the character is out of bounds, the engine finds the closest previous space character and inserts a newline character so the text won't be clipping out of the UI.

This solution, however, doesn't work in Simplified Chinese, Traditional Chinese, and Japanese (all languages Luck be a Landlord is available in).

These three languages very rarely use spaces in their syntax, so how do we backtrack to the previous space character if there isn't one? The answer is to let the game crash since it can't find any spaces, obviously!

...Okay, that was true in some pre-alpha builds of Luck be a Landlord, but the solution is actually to just insert the newline character in-between the first out-of-bounds character and the one just before it.

This can lead to some new issues.

Simplified Chinese description of the Safe symbol with a line break between the "1" and "00" of the "100" number.
This is a Simplified Chinese screenshot of the Safe symbol from a very old build where the Safe gave 0 coins each spin and gave 100 coins when destroyed.

If we just break at the first out-of-bounds character we get a line break between "1" and "00." This isn't syntactically correct in any language as far as I know. So now we need to have logic for certain characters (like numbers) that can't be broken up if the language is set to Simplified Chinese, Traditional Chinese, or Japanese.

But what happens if there's a language where neither of these solutions is sufficient? Enter Thai.

Thai Localization

As I've quickly learned over the past month while getting the Thai version of the game ready, Thai is a language where spaces are rarely used, and the words have a lot of characters in them, resulting in very long strings of characters without spaces between them. Also, you can't just break up a line in-between two characters or it'll look very bad.

It'd be like if I broke a li

ne like this. It doesn't mak

e any sense to write English in this way.

That being said, English words can be broken up in-between syllables. You could break up the word "Book-keep-er" at any of those hyphens so long as the breaks have hyphens as well. This kind of works in Thai, but you need to have an understanding of the language and dictionary in order to do so.

So how do we add line breaks to Thai strings without creating code that can literally understand and parse the Thai language?

The solution is that the translator for the upcoming Thai localization, PlearnGaming, offered to put in a lot of extra work by adding the character for the Thai Baht "฿" anywhere in a string that it would be okay for there to be a line break.

A list of Luck be a Landlord items with their localized Thai names
Some of the Item names localized into Thai.

I just had to tweak the engine in a way that removes all the "฿" characters and considers them for line breaks. Major shoutout to him for that, his work will not go unappreciated.

Screenshot of symbol selection in the Thai version of Luck be a Landlord
No ฿s to be found!

I'm looking forward to bringing the game to new players thanks to another language being supported! If you're able to localize the game into a language that it doesn't support yet, feel free to send me an email with your portfolio.

That's all for now, see you next DevLog!

-Dan