Translate Strings
Step 1: Adding a New Language
Copy the Existing en.json
File
Navigate to the
locales
folder within your script files.Locate the
en.json
file, which contains the English translations.Create a copy of the
en.json
file 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.json
file.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):
After (de.json):
Step 2: Update the cfg.lua
File
cfg.lua
FileChange the Language in cfg.lua
Open the
cfg.lua
file located in your script's main folder.Find the line at the top of the file that sets the current locale:
Replace
"en"
with the language code of the new translation file you created. For German, it should be:
Final Steps
After making these changes:
Save your edited
de.json
andcfg.lua
files.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