Translate Strings
Step 1: Adding a New Language
Copy the Existing en.json File
Navigate to the
localesfolder within your script files.Locate the
en.jsonfile, which contains the English translations.Create a copy of the
en.jsonfile and rename it to the language code of the new language. For example, if you want to add German, rename it tode.json.
Translate the New File
Open the newly created
de.jsonfile.Replace the English text with the corresponding translations for the new language. Make sure to keep the same structure and only change the text values.
For example: Before (en.json):
{
"greeting": "Hello",
"goodbye": "Goodbye"
}After (de.json):
{
"greeting": "Hallo",
"goodbye": "Auf Wiedersehen"
}Step 2: Update the cfg.lua File
cfg.lua FileChange the Language in cfg.lua
Open the
cfg.luafile located in your script's main folder.Find the line at the top of the file that sets the current locale:
lib.locale("en")Replace
"en"with the language code of the new translation file you created. For German, it should be:
lib.locale("de")Final Steps
After making these changes:
Save your edited
de.jsonandcfg.luafiles.Restart your FiveM server to apply the new language settings.
Your script will now run in the newly added language.
By following these steps, you can easily add new language support to your script and switch between them by modifying the cfg.lua file.
Last updated