mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 14:38:50 +00:00
Update Shared.md
This commit is contained in:
1 parent
172408cb92
commit
87f0cf5b71
1 file changed
+13
-4
@@ -1,8 +1,17 @@
|
|||||||
Allows players to set a preferred language and attempt to load locale files in any resources using the module.
|
Allows servers to set a preferred language and attempt to load locale files in any resources using the module.
|
||||||
Locale files should use the [ISO Language Code](http://www.lingoes.net/en/translator/langcode.htm) and be saved as `./locales/langcode.json`
|
Locale files should use the [ISO Language Code](http://www.lingoes.net/en/translator/langcode.htm) and be saved as `./locales/langcode.json`
|
||||||
|
|
||||||
Players can use `setlocale [langcode]`, and admins can use `serverlocale [langcode]` to change the loaded file.
|
To change the preferred language from English, add the convar to your server.cfg
|
||||||
|
```cfg
|
||||||
|
setr ox:locale en
|
||||||
|
```
|
||||||
|
|
||||||
|
Initialise the locale module in your resource (once).
|
||||||
|
```lua
|
||||||
|
lib.locale()
|
||||||
|
```
|
||||||
|
|
||||||
|
Format your strings with the new locale global.
|
||||||
```lua
|
```lua
|
||||||
locale(str, ...)
|
locale(str, ...)
|
||||||
```
|
```
|
||||||
@@ -22,7 +31,7 @@ SetInterval(function()
|
|||||||
end, 5000)
|
end, 5000)
|
||||||
```
|
```
|
||||||
|
|
||||||
```json title="locales/en-US.json"
|
```json title="locales/en.json"
|
||||||
{
|
{
|
||||||
"grand_theft_auto": "grand theft auto",
|
"grand_theft_auto": "grand theft auto",
|
||||||
"male": "male",
|
"male": "male",
|
||||||
@@ -31,7 +40,7 @@ end, 5000)
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```json title="locales/fr-FR.json"
|
```json title="locales/fr.json"
|
||||||
{
|
{
|
||||||
"grand_theft_auto": "vol de voiture",
|
"grand_theft_auto": "vol de voiture",
|
||||||
"male": "homme",
|
"male": "homme",
|
||||||
|
|||||||
Reference in new issue
Block a user