Garry's Mod

Garry's Mod

Florian's Script - Character System
 This topic has been pinned, so it's probably important
Florian #  [developer] Mar 6, 2020 @ 12:43pm
[EN] How do I add additional translations ?
This addon is released with two translated languages by default, however you can easily add new translation languages. There are two ways to do this.

  1. By adding new translations to the "fscript_translations.lua" file in the addon folder.
  2. Using the "FScript.OnLoadScriptTranslations" hook.

If you don't want to modify the translation file and want to "externalize" the changes (a bit like the darkrp modification), use the event, if you are skilled enough, then do it directly in the file.

Method 1: Add translations using the "fscript_translations.lua" file.

This file is located in the "lua" folder of the addon. At the very bottom of the file you will see several times "ADD YOUR TRANSLATIONS HERE, NOT FURTHER DOWN", you will have to insert your translations here and not further down. So just copy/paste one of the two original translations and you can start!

FScript.Lang["EN"] = { TooManyCharacters = "You have reached the maximum number of characters that can be created.", MustBeAlive = "You must be alive to be able to do this action.", MustPlayCharacter = "You have to play a character to be able to do this action.", [...] }

Method 2: Add translations via the "FScript.OnLoadScriptTranslations" hook.

For this method, you will have to create a file that can be read by the server and by the client so for example in "lua/autorun" and that can be called "fscript_mytranslations.lua".

hook.Add("FScript.OnLoadScriptTranslations", "FScript_MyTranslations", function() FScript.Lang["EN"] = { TooManyCharacters = "You have reached the maximum number of characters that can be created.", MustBeAlive = "You must be alive to be able to do this action.", MustPlayCharacter = "You have to play a character to be able to do this action.", [...] } end)

Once the file is created, you will need to add a hook as in the example above and then copy one of the two original translations into it to be able to translate it into another.

FScript.Lang["EN"] ← THE TWO LETTERS IN QUOTES !

What I indicate in bold is the ISO code of the country of your translation, indeed each country has an international identification code, you can find them here[en.wikipedia.org]. If you want to translate into Spanish, then the code will be "ES", in Italian "IT", etc...

Do you find that difficult? Unfortunately, I don't have an alternative to this system to allow to adapt the script language according to the server language.

Remember that if translations are missing or invalid, your translation won't be loaded and an error will be displayed in the console (most likely at the startup of your server). Also, if the language of your server doesn't have a translation in the script, the script will always load the English language.
Last edited by Florian #; Mar 7, 2020 @ 5:53am