My New Translation System (Patreon)
Content
After translating Kingdom Scrolls v2 to different languages (supporting English, Japanese, and Korean) I really want to keep adding language select features to my new worlds. For my upcoming Treasure Hunt world, I had the opportunity to create a new system from the ground up that I could re-use for all my new worlds. So I did that! The world isn't released yet but this particular system is pretty much finished.
The most exciting part for me is that this solution should scale really well if I want to add more languages over time.
So what am I translating? Ideally, any "string" of text that the game uses. These are bits of text that appear on static text boxes in the world OR in procedural messages that might change depending on what's happening in the game-- my games use dynamic text a lot (Example "X/Y Clues Collected" in Murder 4), so if I only translated signs, that would be pretty lame.
The downside to this is that I can't translate text that's baked into a texture, for example a label on a 3D modeled bottle. Well, I could translate those too, but it would take a lot of extra steps. I try not to use textures that have English text baked into them, anyway.
Step 1 is to make a spreadsheet of all the different text "strings." I use Google Sheets for this so that I can share the document with other people like volunteer translators or proofreaders. This system work fine with a local file on your computer, too.
Each row represents a string. The first column is a unique code used to identify that string-- the players won't actually see this. Later, the computer program will need this code to tell the different strings apart. The second column is just a note for the translators to read, and is never used by the game or translation program. Sometimes the strings can be confusing out of context, so it's nice to add some background info for each string like "This string is used to label a button" or "This is a short message the player sees on their screen".
After that, I can add unlimited columns, one for each language. For example, on one row, it might say "Game Master:" in English, followed by the Japanese translation of "Game Master" (ゲームマスター:), etc.
The next step is setting up the scene. For a language select UI, I like to use buttons with the texture of a country's flag. For example, the US flag to select English (Since I write in US English). I also configure each static text box in the scene with special information: The name of the text box should equal the ID code from corresponding row in the spreadsheet. Not all text boxes need to be translated (some are for numbers, URLs, player names, etc). I flag the appropriate text boxes with the word "Localized". This lets my program know that it is a special text box that should change depending on the language.
The next step is to write the actual code that downloads the translations from google into the project (or, if you want to work offline, allow you to upload local data from your computer). I create an "Editor script," which is sort of like an extension to the Unity Editor. This isn't Udon code-- it's just normal C# code that adds stuff to my Unity project. So I can do pretty much anything I want (stuff that Unity can do, but VRChat can't), like download files from the internet. All I need to do is supply the URL of the spreadsheet and make sure anyone (or any computer program) with the URL can download the file. I try to keep this URL super secret though, and only share it with my program and my translators.
To run the Editor Script, I just go to a new menu option I created called "Localization>Import Translations". The program downloads the spreadsheet as one big chunk of text, so I need to split it up into pieces that Udon can understand. After making the program do some basic text parsing (reading and splitting), I end up with a big list of every string in the game and its corresponding versions in different languages, in a form that Udon/VRChat can understand, and saved within the world data.
Finally, I just need to make the flag-buttons translate all the text. I put all the text boxes labeled with "Localized" in a big list. Then, when you press a button (for example Japanese), it knows that you want to choose Language #2. My udon program looks at every text box, notices its unique ID code to find the correct row, then looks at column #2 to find what Japanese text is supposed to go inside.
And that's pretty much it! There are a few other, more complicated uses for translated strings outside of just changing text boxes. But those are barely worth explaining-- basically, as long as I program the game using string ID codes and not just plain old English, I can translate any text in the world. I hope my international players appreciate it!
I am not sure which other languages I will add. If you or someone you know wants my worlds in another language, let me know!