From the reference libraryRedM

i18n <BadgeShared/>

jo_libs/modules/i18n/shared.md

i18n <BadgeShared/>

i18n module is a specialized tool for internationalization within RedM.

Setup

Create a locales folder in your resource and add your locale files there. ::: code-group

return {
    "helloWorld": "Hello World",
    "goodbyeWorld": "Goodbye World"
}
return {
    "helloWorld": "Bonjour le monde",
    "goodbyeWorld": "Au revoir le monde"
}

:::

Load them in your fxmanifest.lua: ::: code-group

files {
    "locales/*.lua"
}

Done, you're all set! :::

Configuration Variables (Convars)

Convar Side Type Default Description
jo_libs:i18n:allowSwitchLocale <Badge type="client" text="Client" /> String true Allow switching locale
jo_libs:i18n:localeCommand <Badge type="client" text="Client" /> String setLocale Command to switch locale
jo_libs:i18n:locale <Badge type="shared" text="Shared" /> String en

JO Functions > jo.i18n.__()

<!-- @include: ./slots/headers.md#shared|jo.i18n.__ -->

Translate a key <br>

<!-- @include: ./slots/descriptions.md#shared|jo.i18n.__ -->

JO Functions > jo.i18n.__() > Syntax

jo.i18n.__(key)

JO Functions > jo.i18n.__() > Parameters

key : string

The key to translate

JO Functions > jo.i18n.__() > Return Value

Type : string

The translated key

<!-- @include: ./slots/examples.md#shared|jo.i18n.__ -->

<!-- @include: ./slots/footers.md#shared|jo.i18n.__ -->


JO Functions > jo.i18n.addEntries()

<!-- @include: ./slots/headers.md#shared|jo.i18n.addEntries -->

Add multiple entries to the i18n dictionary <br>

<!-- @include: ./slots/descriptions.md#shared|jo.i18n.addEntries -->

JO Functions > jo.i18n.addEntries() > Syntax

jo.i18n.addEntries(entries)

JO Functions > jo.i18n.addEntries() > Parameters

entries : table

The entries to add

<!-- @include: ./slots/examples.md#shared|jo.i18n.addEntries -->

<!-- @include: ./slots/footers.md#shared|jo.i18n.addEntries -->


JO Functions > jo.i18n.addEntry()

<!-- @include: ./slots/headers.md#shared|jo.i18n.addEntry -->

Add a single entry to the i18n dictionary <br>

<!-- @include: ./slots/descriptions.md#shared|jo.i18n.addEntry -->

JO Functions > jo.i18n.addEntry() > Syntax

jo.i18n.addEntry(key, value)

JO Functions > jo.i18n.addEntry() > Parameters

key : string

The key to add

value : string

The value to add

<!-- @include: ./slots/examples.md#shared|jo.i18n.addEntry -->

<!-- @include: ./slots/footers.md#shared|jo.i18n.addEntry -->


JO Functions > jo.i18n.findMissingKeys()

<!-- @include: ./slots/headers.md#shared|jo.i18n.findMissingKeys -->

Find missing keys in a locale <br>

<!-- @include: ./slots/descriptions.md#shared|jo.i18n.findMissingKeys -->

JO Functions > jo.i18n.findMissingKeys() > Syntax

jo.i18n.findMissingKeys(locale)

JO Functions > jo.i18n.findMissingKeys() > Parameters

locale : string

The locale to check

<!-- @include: ./slots/examples.md#shared|jo.i18n.findMissingKeys -->

<!-- @include: ./slots/footers.md#shared|jo.i18n.findMissingKeys -->


JO Functions > jo.i18n.getEntries()

<!-- @include: ./slots/headers.md#shared|jo.i18n.getEntries -->

Get all entries <br>

<!-- @include: ./slots/descriptions.md#shared|jo.i18n.getEntries -->

JO Functions > jo.i18n.getEntries() > Syntax

jo.i18n.getEntries()

JO Functions > jo.i18n.getEntries() > Return Value

Type : table

The entries

<!-- @include: ./slots/examples.md#shared|jo.i18n.getEntries -->

<!-- @include: ./slots/footers.md#shared|jo.i18n.getEntries -->


JO Functions > jo.i18n.getLocale()

<!-- @include: ./slots/headers.md#shared|jo.i18n.getLocale -->

Returns the current locale <br>

<!-- @include: ./slots/descriptions.md#shared|jo.i18n.getLocale -->

JO Functions > jo.i18n.getLocale() > Syntax

jo.i18n.getLocale()

JO Functions > jo.i18n.getLocale() > Return Value

Type : string

The current locale

<!-- @include: ./slots/examples.md#shared|jo.i18n.getLocale -->

<!-- @include: ./slots/footers.md#shared|jo.i18n.getLocale -->


JO Functions > jo.i18n.init()

<!-- @include: ./slots/headers.md#shared|jo.i18n.init -->

Initialize the i18n module <br>

<!-- @include: ./slots/descriptions.md#shared|jo.i18n.init -->

JO Functions > jo.i18n.init() > Syntax

jo.i18n.init()

<!-- @include: ./slots/examples.md#shared|jo.i18n.init -->

<!-- @include: ./slots/footers.md#shared|jo.i18n.init -->


JO Functions > jo.i18n.loadLocale()

<!-- @include: ./slots/headers.md#shared|jo.i18n.loadLocale -->

Load a locale <br>

<!-- @include: ./slots/descriptions.md#shared|jo.i18n.loadLocale -->

JO Functions > jo.i18n.loadLocale() > Syntax

jo.i18n.loadLocale(locale)

JO Functions > jo.i18n.loadLocale() > Parameters

locale : string

The locale to load

<!-- @include: ./slots/examples.md#shared|jo.i18n.loadLocale -->

<!-- @include: ./slots/footers.md#shared|jo.i18n.loadLocale -->


JO Functions > jo.i18n.onLocaleChange()

<!-- @include: ./slots/headers.md#shared|jo.i18n.onLocaleChange -->

Register a callback to be called when the locale changes <br>

<!-- @include: ./slots/descriptions.md#shared|jo.i18n.onLocaleChange -->

JO Functions > jo.i18n.onLocaleChange() > Syntax

jo.i18n.onLocaleChange(callback, priority)

JO Functions > jo.i18n.onLocaleChange() > Parameters

callback : function

The callback to register

priority : number

The priority of the callback

<!-- @include: ./slots/examples.md#shared|jo.i18n.onLocaleChange -->

<!-- @include: ./slots/footers.md#shared|jo.i18n.onLocaleChange -->


JO Functions > jo.i18n.setLocale()

<!-- @include: ./slots/headers.md#shared|jo.i18n.setLocale -->

Set the current locale <br>

<!-- @include: ./slots/descriptions.md#shared|jo.i18n.setLocale -->

JO Functions > jo.i18n.setLocale() > Syntax

jo.i18n.setLocale(locale)

JO Functions > jo.i18n.setLocale() > Parameters

locale : string

The locale to set

<!-- @include: ./slots/examples.md#shared|jo.i18n.setLocale -->

<!-- @include: ./slots/footers.md#shared|jo.i18n.setLocale -->

Back to documentation