Addon Localization
language.Add
language.Add will add a localization string for the user's currently selected language. This is mainly used as a developer tool, or for addons that use only 1 language. This method is not suitable if you want to add localization strings for multiple languages.
language.GetPhrase
language.GetPhrase allows you to retrieve a translated string given an "internal" untranslated one.
In most places, you can also write "#your.string"
, which will be rendered as the translated string if a translation for it exists. This method will not work as a substring - that's where language.GetPhrase comes in handy.
.properties files
.properties
files help developers localize addons for multiple languages. This is the same system that Garry's Mod uses. The language files will be loaded automatically based on the user's currently selected language. English (en
) files are loaded before any other language in order to fill potentially missing translations.
Setting this system up for your addon is very simple. What you need to do is create .properties
files in your addon's resource/localization/
folder. The file and folder structure must follow the base game's usage, which is as follows:
resource/localization/
should have folders for each language code your addon supports. This can be any number of languages out of the predefined list at the bottom of this page.- Inside a language folder - for example,
resource/localization/en/
- you should create.properties
files, which contain translations in a key-value pairs format. The filename can be anything, but should ideally represent the name of your addon, be unique (the filesystem is not sandboxed and is therefore shared between all addons), and should generally be the same across all languages within your addon.
The format of these .properties
files is very simple:
- Lines starting with
#
are comments. - Every line is treated as one string, with keys and values separated by the
=
sign. - The part that contains the key ( before the
=
sign ) must not contain spaces. - The first row must currently be left empty containing nothing whatsoever.
Here's an example of such language file spawnmenu.properties
edited with sublime text:
As an example, these can be used in game as "#spawnmenu.content_tab"
or language.GetPhrase( "spawnmenu.content_tab" )
You can find the built-in English localization here.
Of interest is the community.properties
file, which contains a set of commonly used words by the Garry's Mod community, translated for you to every language the game supports.
.properties
files also support the unicode way of writing characters:
Supported languages
Below you will find a complete list of supported languages:
Code | Language |
---|---|
bg |
Bulgarian |
cs |
Czech |
da |
Danish |
de |
German |
el |
Greek |
en |
English |
en-PT |
Pirate English |
es-ES |
Spanish |
et |
Estonian |
fi |
Finnish |
fr |
French |
he |
Hebrew |
hr |
Croatian |
hu |
Hungarian |
it |
Italian |
ja |
Japanese |
ko |
Korean |
lt |
Lithuanian |
nl |
Dutch |
no |
Norwegian |
pl |
Polish |
pt-BR |
Portuguese (Brazil) |
pt-PT |
Portuguese (Portugal) |
ru |
Russian |
sk |
Slovak |
sv-SE |
Swedish |
th |
Thai |
tr |
Turkish |
uk |
Ukrainian |
vi |
Vietnamese |
zh-CN |
Chinese Simplified |
zh-TW |
Chinese Traditional |