Add Translation
Quick Start: Adding New Locales
1. Use Existing Language Files
Edit the existing translation files in: /gamemode/config/locale/[language_code]/
gamemode/config/locale/
├── en/
│ ├── sh_en_config.lua
│ └── sh_en_entities.lua
├── fr/
│ ├── sh_fr_config.lua
│ └── sh_fr_entities.lua
2. Add Translations to Existing Files
The files already use Monolith.LocaleBuilder() with environment setting:
-- In existing sh_fr_config.lua
-- Already has: Monolith.LocaleBuilder("fr", true)
-- Just add your new translations
cfg.item.weapon_pistol = "Pistolet"
cfg.item.weapon_pistol.desc = "Une arme de poing standard"
entities.weapon_pistol.printName = "Pistolet"
entities.weapon_pistol.instructions = "Clic gauche pour tirer"
msg.player_joined = "%s a rejoint le serveur"
msg.money_received = "Vous avez reçu %s$"
msg.player_killed = "%s a été tué par %s avec %s"
3. Use Translations in Code
Method 1: L() Function (Recommended)
-- Simple usage
local itemName = L("cfg.item.weapon_pistol")
-- With formatting (printf style)
local message = L("msg.player_joined", player:Name())
local stats = L("msg.player_stats", health, armor, money)
-- In item definitions
ITEM = Monolith.InventoryItem("pistol", L("cfg.item.weapon_pistol"), L("cfg.item.weapon_pistol.desc"))
-- In entity code
ENT.PrintName = L("entities.weapon_pistol.printName")
Method 2: Monolith.GetPhrase() (Same as L)
-- Identical functionality to L()
local itemName = Monolith.GetPhrase("cfg.item.weapon_pistol")
local message = Monolith.GetPhrase("msg.player_joined", player:Name())
Function Reference
L(phraseID, ...)
Monolith.GetPhrase(phraseID, ...)
Parameters:
phraseID(string): The translation key/identifier...(varargs): Optional parameters for string formatting
Returns:
- Translated string in current language
- Falls back to English if not found
- Returns phraseID if no translation exists
Examples:
-- Basic usage
L("cfg.item.medkit") -- Returns: "Medkit" (en) or "Trousse de secours" (fr)
-- With formatting
L("msg.money_received", 500) -- "You received $500" or "Vous avez reçu 500$"
L("msg.player_killed", victim, killer, weapon) -- "John was killed by Mike with AK47"