To access our library's functions here are two types of access
Export Method
-- add this to the top of all your script files where you want to use the library
local HRLib = exports.HRLib:getLibFunctions()
A couple functions are not available in the export method
Import Method
-- add this in your fxmanifest.lua file:
shared_script '@HRLib/import.lua'
-- or if there are more than one shared scripts defined in your fxmanifest.lua file:
shared_scripts {
'@HRLib/import.lua',
'other_files'
}
In the import, the library's translator is automatically added. If you want to remove it from your script, write this in your fxmanifest.lua file:
remove_translator_import 'yes'
Otherwise, if you want to use it and you use the import method, you should only add this to your fxmanifest.lua file:
file 'translator.lua'
-- or if you have more than one files to register, use this:
files {
'translation.lua',
'other_files'
}
Translation Usage
To use our translator, you should create a new file directly in your script, named translation.lua.
File Format:
return {
bg = {
test = 'text', -- You can access this value triggering Translation.test
test2 = { -- You can add a second table in the translation's table, but you cannot add more
test_again = 'text2' -- You can access this table triggering Translation.test2.test_again
}
},
en = {
test = 'text',
test2 = {
test_again = 'text2'
}
}, -- ....
}
Then write this in your fxmanifest.lua:
-- import method
file 'translation.lua'
-- or if you have more than one file
files {
'translation.lua',
'other_files'
}
-- export method
shared_script '@HRLib/translator.lua'
file 'translation.lua'
-- or if you have more than one shared script and file
shared_scripts {
'@HRLib/translator.lua',
'other_files' -- other files must be registered after the translator file, it is very important
}
files {
'translation.lua',
'other_files'
}