Locales API
All of this comes from bs_core/shared/sh_locale.lua. How to set up a resource for translation is on Locales. This page is the reference.
Languages: en, pt, de, pl, tr, es, fr, it, ru. Missing keys fall back to en, then to the key itself.
Include it
Section titled “Include it”shared_scripts { '@bs_core/shared/sh_locale.lua' }files { 'locales/*.lua' }Each locales/<lang>.lua returns a flat table:
return { ['shop.title'] = 'Trader', ['shop.bought'] = 'You bought {item} for ${price}',}Placeholders are {name}. An unknown placeholder is left as it is, so typos show up instead of disappearing.
Lua functions
Section titled “Lua functions”| Function | Side | What it does |
|---|---|---|
L(key, vars) | client | Text in the local player’s language |
L(key, vars) | server | Text in the server default language |
L(src, key, vars) | server | Text in that player’s language |
Lp(src, key, vars) | server | Same as above, always takes a source |
BSLocale.T(lang, key, vars) | both | Text in a language you name |
BSLocale.Lang() | both | Local player’s language (client) or the default (server) |
BSLocale.LangOf(src) | both | A player’s language, falls back to the default |
BSLocale.Default() | both | Server default (GlobalState.bs_defaultLang, else en) |
BSLocale.IsValid(lang) | both | Is this one of the nine codes |
BSLocale.Dict(lang) | both | The whole table with en underneath, for NUI |
BSLocale.OnChange(fn) | client | fn(lang) runs when the language changes |
BSLocale.Set(lang) | client | Ask bs_core to change the player’s language |
BSLocale.Languages, BSLocale.Native | both | The code list and the native names |
Server export: exports.bs_core:GetLanguage(src).
Always pass the player’s source on the server when the text goes to one player. L('key') without a source uses the server default, which is wrong for a notification.
TriggerClientEvent('bs:ui:notify', src, { type = 'success', message = L(src, 'shop.bought', { item = label, price = 50 }) })- Player choice: state bag
bs_langon the player. - Server default:
GlobalState.bs_defaultLang(F1Global.defaultLanguage, or thebs_defaultLanguageconvar). - Saved per account in
bs_users.language. - Changing it fires the server event
bs_core:setLanguage.
If the resource has a ui_page, the locale script answers the bs_i18n NUI callback with { lang, dict } and pushes the new table when the language changes. Load the helper and mark up your HTML:
<script src="nui://bs_ui/html/js/i18n.js"></script><span data-i18n="ui.level">LEVEL</span>In JS: t('key', vars) and BSI18n.onChange(fn). Details on Locales.
bs19.org · Privacy · Terms · Cookie settings
Cookies and outside content
The site only needs two essential cookies to keep you logged in and protect forms. Videos and streams from YouTube and Twitch load from their servers, which can set their own cookies, so they stay off until you say yes. Nothing is pre-ticked and you can change your mind any time with "Cookie settings" at the bottom of every page. Details.
Questions about the server, the framework or the site? A real person reads this, usually within a day.