S&box Wiki

Revision Difference

localization#550965

<cat>UI.Intro</cat> <title>Localization</title> # What Is Localization Instead of doing `label.Text = "Hello World"`, you do `label.Text = "#helloworld";`. This way you can use the localization system to change `#helloworld` into `こんにちは世界` if they have their language set to Japanese. # Tokens When doing UI stuff if you set a value to a string starting with `#` - it'll become a token, which means it'll look for its real value in the localization system. This works both when creating Panels using code and using templates. # Definitions To create your definitions create a folder in the root of your addon called `.localization`. Then inside that create a folder for the language. `en` is English. Then create a Json file inside that, which will hold your tokens. # Example Filename: `.localization\en\sandbox.json` ``` { "spawnmenu.props" : "models", "spawnmenu.entities" : "entities", "spawnmenu.cloudmodels": "asset.party", "spawnmenu.tools": "tools", "spawnmenu.utility": "utility" } ``` Then our code can do something like this.. ```csharp Add.Button( "#spawnmenu.utility" ); ``` # Languages ⤶ For now there are two languages. English (en) and Pirate (en-pt). We'll add more languages on request and over time.⤶ You can currently use the following languages for localization:⤶ ⤶ | English Name | API 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 |⤶ | Pirate | en-pt |⤶ | 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 |⤶