F5 StudioF5 Studio
Skip to main content

Localization

Every player-facing string in F5 Redeem Code — panels, toasts, notifications and server messages — comes from a locale file, so the whole resource can be translated by editing plain Lua tables.

Bundled languages

The script ships with two languages:

CodeLanguageFile
enEnglishlocales/en.lua
plPolishlocales/pl.lua

Select the active one in the config:

config/config.lua
F5Cfg.Locale = 'en'   -- 'en' or 'pl'

How translations resolve

A locale file assigns a flat key→string table under its code:

locales/en.lua
Locales = Locales or {}

Locales['en'] = {
['redeem_title'] = 'Redeem Code',
['redeem_success'] = 'Code redeemed successfully!',
['reward_item'] = '%s x%d',
-- ...
}

Strings are looked up through two shared helpers (identical behaviour):

_L('redeem_success')          -- "Code redeemed successfully!"
Translate('reward_item', 'Water', 3) -- "Water x3"

Resolution order for any key:

  1. The active language (F5Cfg.Locale)
  2. English (en) as a fallback
  3. The key itself, if it exists in neither

Extra arguments are passed through string.format, so placeholders like %s and %d are filled in safely (a malformed format string falls back to the raw string instead of erroring).

English is the safety net

Because English is always the fallback, a translation file may be partial — any key you don't translate automatically shows the English text. You never end up with a blank or a raw key on screen.

Server vs NUI strings

  • Server-side messages (redeem results, admin notifications) are translated with Translate(...) and sent to the client.
  • NUI strings are delivered as a bundle: on every panel open the server calls BuildLocaleBundle(), which merges the full English table as a base and overlays the active language, then ships it to the interface. The panel renders labels from that bundle.

The special key locale_code (e.g. en-US) is provided for locale-aware formatting inside the NUI.

Adding a language

  1. Copy locales/en.lua to locales/<code>.lua (e.g. locales/de.lua).
  2. Rename the table to your code:
    locales/de.lua
    Locales = Locales or {}

    Locales['de'] = {
    ['redeem_title'] = 'Code einlösen',
    ['redeem_success'] = 'Code erfolgreich eingelöst!',
    -- ... translate every value
    }
  3. Translate the values only — keep the keys unchanged. Preserve %s / %d placeholders and their order.
  4. Update locale_code to your locale (e.g. de-DE).
  5. Point the config at it:
    config/config.lua
    F5Cfg.Locale = 'de'
  6. Restart the resource.

New files are picked up automatically — the manifest loads locales/*.lua, so there's nothing else to register.

Keep keys in sync

The set of keys is defined by locales/en.lua. When you update the script and new keys are added there, add them to your translation too — until then those specific strings fall back to English.

See Also