Translations

Translation Guide

This guide explains how to create a new language for any script that depends on lc_utils.

Use exactly the same locale code in every file. If you choose it, create lang/it.lua, nui/lang/it.js, lc_utils/lang/it.lua and set Config.locale = "it" in lc_utils/config.lua.

How the translations are organized

  • Each script has a lang folder for Lua translations used by the client and server script files.
  • Each script also has a nui/lang folder for the browser UI, such as buttons, tabs, tooltips and modal text.
  • lc_utils has its own lang folder for shared text such as confirmation modal buttons, notification titles, validation messages and progress bar text.
  • The active locale is selected centrally in lc_utils/config.lua, so every dependent script must have a file for the same locale code.

Steps to create a new translation

Duplicate language files

Each script has two language files (lang/en.lua and nui/lang/en.js), plus lc_utils has its own (lc_utils/lang/en.lua). For each one, duplicate the English file, rename the copy using your locale code:

File to duplicateRename to
<script>/lang/en.lua<script>/lang/<locale>.lua
<script>/nui/lang/en.js<script>/nui/lang/<locale>.js
lc_utils/lang/en.lualc_utils/lang/<locale>.lua

Translate the texts

Open each file and update the locale key and the translated values. For example, using it:

<script>/lang/it.lua:

if not Lang then Lang = {} end
Lang['it'] = {
    ['markers'] = {
        ['open_refuel'] = "Premi ~INPUT_CONTEXT~ per fare rifornimento",
        ['open_recharge'] = "Premi ~INPUT_CONTEXT~ per ricaricare",
    },
    ['blip_text'] = "Stazioni di servizio",
}

<script>/nui/lang/it.js:

if (Lang == undefined) {
    var Lang = [];
}
Lang["it"] = {
    pumpInterface: {
        confirm: "CONFERMA",
    },
    confirmRefuelModal: {
        title: "Conferma rifornimento",
        paymentBank: "Paga con la banca",
        paymentCash: "Paga in contanti",
    },
}

lc_utils/lang/it.lua:

Utils.Lang['it'] = {
	['confirmation_modal_title'] = "Conferma azione",
	['confirmation_modal_cancel_button'] = "Annulla",
	['confirmation_modal_confirm_button'] = "Conferma",
	['notification'] = {
		['error'] = "Errore",
		['success'] = "Successo",
	},
}

Activate the locale in lc_utils

After creating the files, open lc_utils/config.lua and set the new locale:

Config.locale = "it"

Translate config values when needed

Some texts are not stored in the language files and must be translated directly inside config.lua. So just open the file and look for any values that need to be translated and update them with the new language.