-
Notifications
You must be signed in to change notification settings - Fork 0
Localization en US
The ability to translate your map into different languages indicates that in Hammer you need to pass to the function not directly a line of text, but only its key. The client part of the game independently, based on the selected language, will determine by the key which line needs to be displayed on the screen. Your task is to write these lines for each transmitted key in your native language, and then involve translators or your language knowledge to translate these lines into as many languages as possible. The translation will be discussed on this page.
TL;DR The scripts utilize the default localization scheme in Garry's Mod via .properties files.
These scripts accept files in the .properties format as localization files, one language per file. Below is an example of this format:
ps.text_2_3=You should check the yellow garage for it.
ps.text_2_4=And if you find it burn it to ashes.
ps.text_2_5=Please hurry, or...
ps
-- this is the prefix of all keys, determined at the configuration stage. This is some kind of string that all your localization keys will definitely start with.
text_2_3
, text_2_4
, text_2_5
-- these are the arguments that you would like to pass from Hammer.
For example, if the localization prefix is set to ps
in the config, and you pass my_text
from Hammer, as a result, the game will search in .properties localization files for a string like ps
+.
+my_text
= ps.my_text
.
During the translation process, difficulties may arise related to the rules for writing .properties files. Most languages have letters other than Latin, but you can't just write to a file, for example,
ps.text_2_3=Посмотри в жёлтом гараже.
ps.text_2_4=И если найдёшь — сожги.
ps.text_2_5=Пожалуйста, поторопись, иначе...
Every letter other than English, as well as the equal sign, colon, lattice and exclamation mark need to be "escaped". If you do it manually, it can take a lot of time. The result will be an unreadable file, which will be very difficult to navigate. It is easier to use programs that allow you to easily edit .properties files.
An example of such a program is JLokalize. It allows you to create translations for different languages, shows which keys have not yet been translated, and most importantly - takes all the dirty work in the form of escaping on yourself. The program will need Java to work.
TL;DR This page will mostly be devoted to working in this program. At the end, it describes where to put the resulting .properties files to make everything work.
After launching the program, you need to create a new file in which you define the keys and their corresponding values in your native language. It is better to take the language that you know best as the main one, then you will be able to write the text most accurately for yourself, and then give it to people who know this language and some other.
Photo
You can name the project as you like (preferably using only English letters and numbers), the corresponding file will be named in the form of projectname.properties
. After creation, the project name will appear in the upper left corner (in the list of languages) with the note "(Master)", meaning that JLokalize will focus on this file by checking untranslated keys in other languages.
Create the first key by clicking on the corresponding button in the upper panel. In the suggested window, enter its name in the format 'prefix.key` (see "Localization file structure")
Photo
A new key has appeared in the Keys panel. There is a red marker next to its name, meaning that this key has not yet been saved to the final file. In the "Translation" field, you can write the original line of text under this key, and then save the project (Ctrl+S). Select the folder where you want to save the project. It is better to create a separate directory for this, because JLokalize creates a separate .properties file for each language (which is what we need).
Photo
Now you need to write down all the other lines used by your map, creating a key for each line in JLokalize.
Photo
In the top panel of JLokalize, click "Add new language". A dialog opens with the language selection. Find the desired language in the table below (Garry's Mod supports only these languages) and specify the appropriate language and country codes (if available):
Language | Country | Language name | | | Language | Country | Language name |
---|---|---|---|---|---|---|
bg |
Bulgarian | | | cs |
Czech | ||
da |
Danish | | | de |
German | ||
el |
Greek | | | es |
ES |
Spanish | |
en |
English | | | en |
PT |
Pirate English | |
et |
Estonian | | | fi |
Finnish | ||
he |
Hebrew | | | hr |
Croatian | ||
hu |
Hungarian | | | fr |
French | ||
it |
Italian | | | ja |
Japanese | ||
lt |
Lithuanian | | | nl |
Dutch | ||
no |
Norwegian | | | ko |
Korean | ||
pl |
Polish | | | pt |
BR |
Portugese (Brazil) | |
ru |
Russian | | | sk |
Slovak | ||
sv |
SE |
Swedish | | | pt |
PT |
Portugese (Portugal) |
th |
Thai | | | tr |
Turkish | ||
uk |
Ukrainian | | | zh |
TW |
Chinese Traditional | |
vi |
Vietnamese | | | zh |
CN |
Chinese Simplified |
Photo
After that, the created language will appear in the list of languages, and when it is selected at the bottom left, the translation progress will show "0%", which means that not a single line specified in the source material has yet been translated into this language.
Photo
You can select a key in the "Keys" panel and translate its string, focusing on the string of this key in the source material, which is displayed at the top. When you click on the "Use" button, the source material is copied into the translation text window. As the project is filled out after each save, the translation progress will be updated.
Photo
After editing is completed, several files can be found in the folder where the project was saved.:
Each file stores the translation of your lines for a separate language, and the main file (which does not have a _
in its name) contains the source material. These files need to be "spread" into the appropriate folders in the format required by Garry's Mod. In the folder of your addon, create the folders resource/localization
. In localization
, create a folder for each of the translated languages, name them in the format lang-COUNTRY
, where lang
is the two-letter language code from the table above, and COUNTRY
is the two-letter country code from the table above (if there is such a code in the table). The language code should be written in lowercase letters, and the country code in uppercase letters. The names of localization files that have the format projectname_lang_COUNTRY.properties
can serve you as a guide. Note that lang
and COUNTRY
in the names of these files are separated by an underscore, and in the names of folders they need to be separated by a dash.
The final structure should be as follows: