- Dec 28, 2023
- 88
- 45
This is a case study in how to translate a visual novel so people understand what the process actually entails which can be used for educational and other purposes.
This goes through the actual steps required to develop a workflow that can be used to translate an arbitrary VN on an arbitrary game engine using traditional translation techniques. This does not cover translation via application hooking. For translators, the procedure for figuring out how to create patch is more useful than just having a translated patch or vague instructions since the concepts can extend to other languages besides English, translations for games, and game engines.
Warning: If there are no tools to work with a game engine, then developing them or asking/hiring a developer to develop them may be required. Luckily, this one did not happen to need any of that.
Since I received a request for help in translating Kinbaku Ouji, Lit: Bound Prince, I decided to document the steps here. That is what is meant by "case study". This is not a general procedure for how to translate VNs, or even other VNs for this game engine, but rather the specific tangible steps required to translate this specific VN. Some steps are generalizable, but others are not.
Kinbaku Ouji can be download here. According to VNDB, it looks to be a BL fanfic of Death Note, which is an Anime/Manga series.
The first thing to do is to extract the game and make sure it works. If it does not work normally untranslated, then there is no point in trying to translate it since it does not work anyway.
Launching "緊縛王子.exe" with a JPN locale emulator seems to make it work and it loads the first script.
Take a screenshot or otherwise note the first line of the game. It is the goal of a "proof of concept" to change that line to a different language. As long as the proof of concept is completed, then the only thing left is the actual work of translation since the proof of concept verifies the workflow required to translate the game's dialogue and/or images.
Since the VN works, it is time to close it and try to unpack the assets.
Games have different types of assets like audio files, video, images, program settings, save data, and, the most important one for our purposes, scripts for the untranslated dialogue. Developers normally pack their assets into archives, similar in concept to .zip files, and then rely on the game to unpack them dynamically at runtime. Unpacking assets means working with archives. Working with visual novel archives usually means using GARbro, Game Resource Browser.
For VNs, always try GARbro first before trying anything else. GARbro supports a lot of formats, some mainstream some very obscure. It can even write some, but not all, types of archives. It can read from more archives than it can write since developing a parser for reading files from archives is easier than developing a parser to pack those same files into archives. There is also a lot more demand for reading due to people wanting access to OSTs, and CG galleries so once a developer has written a parser, they often choose to let someone else handle the more difficult work on packing if they are not interested personally.
- Open GARbro.
- Copy/paste the game's location to the top navigation bar and press enter or navigiate to the game directory manually.
Next, try opening the script.dat file.
Okay, so GARbro can read the script.dat archive and see there are files inside. Let's try extracting everything. ctrl + A to select everything. Right-click somewhere in the file selection window and select Extract. Pick an extraction path that makes sense, like under a new folder called extracts in the main game directory or similar. Using the archive.dat name in the folder name also makes sense. So for this one it would be main_game\extracts\script\ or similar.
Just because GARbro can unpack files does not mean it is doing so correctly. Sometimes files or obfuscated or encrypted using information GARbro is not aware of. Is this one of those cases? Double click on the ".. <DIR>" line in GARbro to go up one folder level and then enter another .dat file. The other files should have images or sound. Let's try looking at an image or extracting an audio file and see if it plays normally.
It looks like bmp.dat has pictures and GARbro can display it natively. That means it can correctly display pictures from bmp.dat which dramatically increases the odds that it is extracting the script files correctly. Extracting an audio or image file would work to double-check that, but it seems to work, so let's just move on.
Okay, so unpacking using GARbro works. Let's open the script in Notepad++ and see what the script file looks like.
While in Notepad++, double check the line ending is either UTF-8 or Shift-JIS, as those are the two most common encodings for Japanese language VNs. Character encodings are different ways of representing characters like letters, numbers, control characters, and characters for complicated languages like Chinese and Japanese. Not all encodings can support all characters. Looking at the text file with the wrong encoding results in mojibake, so always make sure to look at them using the encoding they were created in. Only use UTF-8 if at all possible. For Japanese VNs, especially old ones, the encoding is usually Shift-JIS, so make sure that is selected at the bottom right in Notepad++. If it is not autodetected, select it manually: Encoding->Character sets->Japanese->Shift-JIS.
Hummm. That is not a normal text file. Still, there are large chunks which are readable in Japanese using the Shift-JIS encoding. From those two pieces of information, that means it is a binary encoded text file which is a text file that uses weird game engine specific formatting for the text. I will define game engine in a bit. Dealing with that will probably be a pain. Let's deal with it later.
The more immediate question is: does packing work?
As cool as it is to unpack stuff, it is not possible to translate anything purely by unpacking the assets. From a technical perspective, packing/displaying is the hard part. To verify the workflow of translating a game using traditional methods, unpacking->translating->packing must be done. Without that, there is no way to create the "proof of concept" that verifies that the translation can actually be done. That said, unpacking is a huge clue about how to pack it. So in the worst case, writing a packer based upon the unpacker should be theoretically possible.
With our goal clear, time to figure out if packing works or not.
- Go back to GARbro.
- Go to the script folder that has the extracted script files.
- ctrl + A to select all.
- F3 or File->Create archive.
- Click on the archive format box.
Which of those archive formats looks like it might work?
- Try all of the ones that look like they might have the same extension of ".dat".
- After creating the archive, move the created archive to the main game directory.
- Double checked that it is named exactly the same including cAsE.
- Be sure to backup the original script.dat file if that has not already been done.
- Launch the game using a Japanese locale emulator or with the locale set to Japanese, Japan.
The game just sort of loops at the home screen whenever it fails to load the archive.
- Return the original script.dat file to the game folder.
- Launch the game using a Japanese locale emulator or with the locale set to Japanese, Japan.
- It should work again.
- Replace it with the GARbro created .dat and it should break again.
In other words, the original script.dat works, but GARbro created script.dat does not work. Since packing using GARbro did not work, it is time to dig deeper!
Opening the *.dat files, like script.dat, in a text or hex editor reveals the string 'PACKDAT' as the first few characters. That is the header or identifier for that file type. Notepad++ is fine for just the first look. An actual hex editor like wxHexEditor that supports Shift-JIS character encoding is recommended if you are trying to reverse engineering anything, like the script format which is going to need to be done eventually.
Since Garbro can open them, it must have code related to that archive type. Here is the source tree for various Garbro archive formats.
https://github.com/crskycode/GARbro/tree/master/ArcFormats
Searching through the list for the string 'PACKDAT', 'PACK', and 'DAT' eventually reveals that the archive format is defined in this file.
https://github.com/crskycode/GARbro/blob/master/ArcFormats/ArcPACKDAT.cs
If you read the code, it obviously only supports unpacking, not packing. If you can't read code, then the last line in the following code block makes that obvious for non-coders as well.
Code:
public override string Tag { get { return "PACKDAT"; } }
public override string Description { get { return "SYSTEM-ε resource archive"; } }
public override uint Signature { get { return 0x4B434150; } } // "PACK"
public override bool IsHierarchic { get { return false; } }
public override bool CanWrite { get { return false; } }
The "CanWrite" header for the archive format returns "false" which probably means that it cannot write that archive format which means none of the options in the UI could have possibly worked.
But before writing a custom packer for that PACKDAT archive format, maybe someone else has already written one?
I tried searching for "SYSTEM-ε resource archive", "System Epislon," and similar but did not find anything. Dead end, at least for me.
Going back to the Garbro source code file ArcPACKDAT.cs, at the top it has this.
Code:
//! \file ArcInnGrey.cs
//! \date Mon Jan 19 08:57:16 2015
//! \brief Innocent Grey archives format.
The file is called ArcPACKDAT.cs, not ArcInnGrey.cs, but that header does not reflect that. It must be an old header. That modified date more or less says the same thing: it is an old file. Since the file used to be called ArcInnGrey.cs, but was renamed, then what exactly is "ArcInnGrey"? It is probably short for "Archive InnGrey" What is "InnGrey"? Looking at the next line, it says "Innocent Grey archive format," so "InnGrey" is probably "Innocent Grey". Still, what is Innocent Grey? Is it a game engine or a company or something? Never heard of it.
A game engine is the core part of a video game that actually does everything like loading images, audio, video, supporting save/load functionality, loading dialogue scripts, and everything else. It is possible to develop multiple games using the same game engine. The only thing the developer changes in that situation are the Audio/Visual assets, and dialogue scripts. Sometimes a developer might also might make slight changes to the game engine over time.
Dumping "Innocent Grey" into a search engine leads to, among other things, reddit.
"I am midway through Kara no Shojo 2 after completing KNS1," --reddit
What is "Kara no Shojo 2"? Going by the subreddit name, is that a VN? Searching for "Kara no Shojo 2 VNDB" leads to its VNDB page.
https://vndb.org/v5922
Code:
Developer Innocent Grey
How interesting. In other words, "Innocent Grey" is a developer, not necessarily a game engine. That said, some developers use their own in-house game engines, so it might be both in this case. Other developers use more well known game engines like NScripter or kirikiri. What game engines is developer Innocent Grey known to use?
Looking down at the Releases>English section, it looks like it has a few official releases, and very interestingly, it has at least one unofficial release.
https://vndb.org/r75113
In other words, the group Oneline's Workshop found a way to translate the game and they have done a few other games. Are those other games that Oneline Workshop translated also Innocent Grey games? Is this particular Innocent Grey game using an in house engine, did they switch at some point, or what? Some developers do that. How did Innocent Grey develop their past games?
Here is the VNDB page for Innocent Grey as a developer. https://vndb.org/p277
Do any of Innocent Grey's past releases have fan translations using any engine including possibly an in-house "Innocent Grey game engine"? I could search through that list, but Oneline's Workshop already translated one of their games. Maybe they did more from the same developer and there is a record that confirms they were working with a particular game engine?
https://vndb.org/p11576 And clicking on every link gives this list.
https://vndb.org/r104371
https://vndb.org/r77942
https://vndb.org/r81764
https://vndb.org/r81028
https://vndb.org/r75113
https://vndb.org/r70062
https://vndb.org/r66338
How lucky. That first link for Kara no Shoujo - The Last Episode Prequel, https://vndb.org/r104371 , has an interesting link.
Code:
Engine InnocentGrey
*click*
https://vndb.org/r?f=fwInnocentGrey-
That 'f=fw' syntax in VNDB links means the next part of the string is a type of game engine. In this case the "Innocent Grey" game engine is internally referred to by VNDB as "InnocentGrey". Intuitive, unlike Garbro's naming system. So, the "Innocent Grey game engine" does exist after all.
Anyway, it looks like most of the titles that VNDB is aware of that use the Innocent Grey game engine are titles that have Japanese language releases but not English ones except for 1, that Kara no Shoujo patch.
Going back to Oneline's Workshop, https://vndb.org/p11576 , how did they translate that game using the Innocent Grey game engine? Do they have any tools for it? They have a discord link, so social people can join their discord and ask them.
Alternatively, maybe they published their tools somewhere already? Where would someone publish tools to manipulate game engines for VNs? Maybe on Github? Maybe VNDB? Maybe fuwanovel?
Github is the largest repository for open source projects online. Let's search there first. So let's go over to Github and search for something. Search for what exactly? Well, if Kara no Shoujo has a patch, then maybe the patch itself was uploaded to Github. Alternatively, maybe the Kara no Shoujo Japanese characters would work, 虚ノ少女, or the game engine. Let's try the game engine.
https://github.com/search?q=Innocent grey&type=repositories
On the left it says Code, Repositories, Issues, Pull Requests. Maybe repositories is the correct one, but maybe not. If Repositories fails, there are other categories to look for clues.
Let's see. Time to read the descriptions.
Code:
lennylxx/IG_tools
Tools to process the game files by Innocent Grey & Noesis, for translation.
RikuKH3/igapack
Innocent Grey Archive Unpacker/Packer
Those both look interesting. *click*
https://github.com/lennylxx/IG_tools
https://github.com/RikuKH3/igapack
It looks like igapack is for .iga files. Are those image files or something? That might work but the lack of a detailed readme is disapointing. What does the other one say? IG_tools mentions *.s script files. Bingo!
Now for the moment of truth. What language did they program in? Languages: C++ 98.1% Miss! Damn. C++ needs to be compiled to work. If it was written in a language that uses an interpreter, it would be possible to get to work almost always, but with compiled languages, only the original developer is in a position to compile it without it being a massive headache because only the original developer knows what environment they developed it in. How is anyone besides the developer supposed to know how to compile it if they did not provide step-by-step instructions with excessive levels of detail and scripts to compile their software? The word 'compile' does not even appear in their readme. How typical. *sigh* My hopes are thoroughly dashed.
Well, maybe they were not spiteful to their potential users and took the time to compile their software so real people could actually use it instead of leaving it as source code that is only useful to developers? Many software developers never bother never both to compile their software because real word use, who cares about that right? Well anyway, what does the releases page say?
https://github.com/lennylxx/IG_tools/releases
Ooooh. There is a file called "igtools.zip" How interesting. How unexpected. Maybe it even contains binary files? Does it really? Did they take the time to compile their code and upload it? Really?
Let's try downloading it, scanning it with AV, and then looking inside of the archive. No hits on AV, but that does not mean much since AVs are a black-list style approach. The archive has some binary files though which is very promising. That means the developer really did compile their code. How thoughtful. It seems they want people to use their software after all despite coding in C++. How very unexpected.
Looking back at their readme it says how to use the tools.
Code:
1.use igtool.exe to extract script archive file.
igtool -x script.dat
2.enter the new script~ folder and use igscript.exe to parse the script file.
igscript -p 00_0000.s 00_0000.txt
3.after 00_0000.txt is edited, create the new script file.
igscript -c 00_0000.s 00_0000.txt new\00_0000.s
for CureGirl and フリフレ2, you need to add an extra option -x.
igscript -x -p 0000.s 0000.txt
igscript -x -c 0000.s 0000.txt new\0000.s
Last edited: