Language Files in Half-Life 2 Games GUI.
This tutorial is based around Day of Defeat Source and the different languages it supports, the descriptions and techniques here should work OK with other games like Counter-Strike Source too.
Language support for custom items is something I never thought of… being a typical English speaking Australian I don’t have a second language nor do we have the same geographical borders as places such as Europe where the cultures are close together. So excuse me for being globally ignorant of language barriers.
The way VALVe deals with different languages is Localization files. Put simply when they make a panel that displays on your screen, instead of naming a button or a title directly in the file that displays the panel, VALVe uses special names in the item … then the actual word is handled by another file. This means all the files that make the many panels in the GUI do not have to be remade for every language… just one extra file per game directory is needed! Great idea.
Lets look how VALVe make the Day of Defeat Source Team Menu Panel work. Note that this is only at a local game folder level... .res and .txt files, no change in .dll's or anything at that level.
First they made a .res file that controls the items that display on the screen. It is called Teammenu.res and it is in the dod/resource/UI Folder.
When you open these files (see here for info on tools to use for viewing and editing .res files ) you will notice they are divided up into sections for the separate items on the Team Menu.
Notice this line … "labelText" "#Dod_Join_Team"
That “lableText” controls what displays what you will see on the screen, in English it looks like this…
The answer is in the games resource folder, if you browse the GCF file you will find a lot of files that have the prefix “dod_” and a language name after that…
But it does not say "#Dod_Join_Team" it says "SELECT A TEAM" …. How does it do that?
The "#Dod_Join_Team" is in every one of them as …
"Dod_Join_Team" "SELECT A TEAM"
French (dod_french) …..
"Dod_Join_Team" "SELECTIONNEZ UNE EQUIPE"
"[english]Dod_Join_Team" "SELECT A TEAM"
That’s where the actual wording of the Team Menu main title is handled, not in the actual teammenu.res file. These files handle the words displayed on your screen. In the case of the French language, if steam has been set to the French language, it will use the dod_french file not the dod_english file…
So now you know how the words from the 18 or so different languages display, in short it’s like this…
Now, looking at that image you can see the words are different from the English one. I can also see a problem too. Some of the words do not have enough room to display! More on that latter.
The format for this file to convert the word displayed is quite simple. First the dod_english version is made…
"Dod_Join_Team""SELECT A TEAM"
All other Languages have a different format…
"Dod_Join_Team""SELECTIONNEZ UNE EQUIPE"
"[english]Dod_Join_Team""SELECT A TEAM"
You notice the localized language is first and the original English one is below that.
Ifyou wanted to change the "Dod_Join_Team" Title you can edit the displayed word "SELECTIONNEZ UNE EQUIPE" .
You can also add new entries based on that format. In the case of my HUD’s and Team Menus I have added new sections; in these new sections are Titles and Button names. My mistake when making items like the Team Menu’s was editing the Teammenu.resfile only and putting the word directly into each "labelText" line of the sections…
Ok… it’s wrong to do that but I had no idea my stuff would get downloaded in different languages.
Here is what I should have done…
That method of having a special international version of a custom file that contains labels of buttons and such for VGUI screens is the best way I can think ofto support other languages. It has one major stumbling block… stops me cold, I only know english.
Sometimes google translate can get close, if it is a simple set you may be fine, but always get the text checked if you can.