menu_bookDocumentation
Localization (i18n)
Localization (i18n)
Support multiple languages using localization tokens.
How It Works
Use tokens starting with # in UI strings. The system replaces them based on the user's language.
Creating Translation Files
Create JSON files in Localization/{language}/:
JSON
// Localization/en/sandbox.json
{
"menu.helloworld": "Hello World",
"spawnmenu.props": "Models",
"spawnmenu.tools": "Tools",
"spawnmenu.cloud": "sbox.game",
"game.kill": "{player1} killed {player2}"
}Using in Razor UI
RAZOR
<label>#spawnmenu.props</label>
<button>#menu.helloworld</button>Available Languages
| Language | Code |
|---|---|
| Arabic | ar |
| Bulgarian | bg |
| Simplified Chinese | zh-cn |
| Traditional Chinese | zh-tw |
| Czech | cs |
| Danish | da |
| Dutch | nl |
| English | en |
| Finnish | fi |
| French | fr |
| German | de |
| Greek | el |
| Hungarian | hu |
| Italian | it |
| Japanese | ja |
| Korean | ko |
| Norwegian | no |
| Polish | pl |
| Portuguese | pt |
| Portuguese-Brazil | pt-br |
| Romanian | ro |
| Russian | ru |
| Spanish-Spain | es |
| Spanish-Latin America | es-419 |
| Swedish | sv |
| Thai | th |
| Turkish | tr |
| Ukrainian | uk |
| Vietnamese | vn |
| Pirate | en-pt |
C# API
CSHARP
// Get localized string
string text = Sandbox.Localization.GetString("#menu.helloworld");
// Format with variables
string killMsg = Sandbox.Localization.Format("#game.kill", player1.Name, player2.Name);Best Practices
Was this helpful?