Join the discord

Zeit2 [squared] - rebuilding your own Zeit2.resources.dll

30 Nov, 2011 23:23
So you like modding games, eh? Here's something for anyone interested in translating Zeit2.

By default the game comes with the following languages included - English(Default), Spanish, Italian, French and Deutsch.
The language file for any of these is named "Zeit2.resources.dll" and it's based to its own folder in Zeit2 directory, using the two letter ISO code of the acoording country. The English language, as default is hard coded into the engine files, but the rest like Deutsch is located in "de" folder, Spanish is in "es" ("Espana" in Spanish) and so on.
For a reason unknown to my humble person, the authors decided to use Windows "Location" language to determine which language file to be loaded.

Like it or not, I'm a Bulgarian and Bulgaria's two letter ISO country code is "bg", so when i start the game, it checks if the file "Zeit2.resources.dll" exist in the "bg" folder.

Now don't be too surprised here, (*irony*) but there is no Bulgarian translation so the game will use the built in English language.

Most of the games these days uses human friendly "text strings" files like XML, INI, TXT and etc. This game however is created with Microsoft's game development software built in -hold on now- .NET (!!) called XNA so move on - nothing "friendly" to see here.

I really don't have any idea why game developers do such things. It's not a crime to translate a game to foreign language, right? I understand protecting the game's artwork/music/sounds/etc because someone may really steal it and use it in his products, but what's up with the texts? Any copyrighted catchphrase or something?

Well carry on, let's see what can I do for the rest of the world...

Since i mention the game is built in XNA, its files are compiled with .NET. The language files are also build with .NET so I'll decompile the Spanish (mmm paella...) localization file in .NET Reflector.


It looks quite simple.
The only reference is to "mscorlib", which is the base library for .NET. There is no processes also, just the base "{} -".
At the end is the Resource section "Zeit2.Localisation.Zeit2Strings.es.resources".

Now let's see the "Zeit2.Localisation.Zeit2Strings.es.resources" data:


Here's strings in a standard .NET string resource file.
I can now select all the rows, and copy them.
Unfortunately, my Spanish is "inexistente", so i cheated here and instead copying the Spanish strings i loaded "zeit2.exe" in .NET Reflector to take the English version of this table...

The copied data is formated by "key=value" and it looks like this:
raw dumpArcadeSector1=Stage 1
ArcadeSector1Chapter1=Intro
ArcadeSector1Chapter2=Ghosts

Because .NET uses XML for the string resource the lines below should be formated in XML like this in the resx file:
XML dump<data name="ArcadeSector1" xml:space="preserve">
    <value>Stage 1</value>
</data>
<data name="ArcadeSector1Chapter1" xml:space="preserve">
    <value>Intro</value>
</data>
<data name="ArcadeSector1Chapter2" xml:space="preserve">
    <value>Ghosts</value>
</data>

However, as usual in real life, things are not that simple. Some of the "values" contains characters like "<", ">" and "&" so they should be "encoded" in their safety forms - "&lt;" for "<", "&gt;" for ">" and "&amp;" for "&".

Other than that, the rest is simple.


I created a new C# project in MS Visual C# 2010 Express and .NET Framework 4 and configure it like this:


The "Assembly name", "Default Namespace" and the resx name are most important. For a compatibility reasons the framework also should be set to version 2.

Unfortunately, the game fonts doesn't support Cyrillic letters so i just changed the first menu item to check if will work:


Well... they did work, so here's my C# project, tuned for Bulgarian language - Download.

Comments

* You have an opinion? Let us all hear it!

There's no comments on this article yet. Be the first!
© nullsecurity.org 2011-2024 | legal | terms & rules | contacts