Skip to content

Commit

Permalink
feat: ox_lib locales (#77)
Browse files Browse the repository at this point in the history
* add locale

* Create en.json

* Update consumables.lua

* Update cruise.lua

* Update editor.lua

* Update en.json
  • Loading branch information
bicatcho11 authored Feb 25, 2024
1 parent 28c2bde commit 834c95f
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 28 deletions.
36 changes: 18 additions & 18 deletions client/consumables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ lib.callback.register('consumables:client:Eat', function(itemName)
local item = sharedConfig.consumables.food[itemName]
if lib.progressBar({
duration = 5000,
label = 'Eating...',
label = locale('progress.eating'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -167,7 +167,7 @@ lib.callback.register('consumables:client:Eat', function(itemName)
TriggerServerEvent('hud:server:RelieveStress', math.random(item.stressRelief.min, item.stressRelief.max))
return true
else -- if canceled
exports.qbx_core:Notify('Canceled...', 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
return false
end
end)
Expand All @@ -176,7 +176,7 @@ lib.callback.register('consumables:client:Drink', function(itemName)
local item = sharedConfig.consumables.drink[itemName]
if lib.progressBar({
duration = 5000,
label = 'Drinking...',
label = locale('progress.drinking'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -202,7 +202,7 @@ lib.callback.register('consumables:client:Drink', function(itemName)
TriggerServerEvent('hud:server:RelieveStress', math.random(item.stressRelief.min, item.stressRelief.max))
return true
else -- if canceled
exports.qbx_core:Notify('Canceled...', 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
return false
end
end)
Expand All @@ -211,7 +211,7 @@ lib.callback.register('consumables:client:DrinkAlcohol', function(itemName)
local item = sharedConfig.consumables.alcohol[itemName]
if lib.progressBar({
duration = math.random(3000, 6000),
label = 'Drinking liquor...',
label = locale('progress.drinking_liquor'),
useWhileDead = false,
canCancel = true,
disable = {
Expand Down Expand Up @@ -243,15 +243,15 @@ lib.callback.register('consumables:client:DrinkAlcohol', function(itemName)
end
return true
else -- if canceled
exports.qbx_core:Notify('Canceled...', 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
return false
end
end)

RegisterNetEvent('consumables:client:Cokebaggy', function()
if lib.progressBar({
duration = math.random(5000, 8000),
label = 'Quick sniff...',
label = locale('progress.popping_pills'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -272,14 +272,14 @@ RegisterNetEvent('consumables:client:Cokebaggy', function()
TriggerEvent('evidence:client:SetStatus', 'widepupils', 200)
cokeBaggyEffect()
else -- if canceled
exports.qbx_core:Notify('Canceled...', 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
end
end)

RegisterNetEvent('consumables:client:Crackbaggy', function()
if lib.progressBar({
duration = math.random(7000, 10000),
label = 'Smoking crack...',
label = locale('progress.smoking_crack'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -300,14 +300,14 @@ RegisterNetEvent('consumables:client:Crackbaggy', function()
TriggerEvent('evidence:client:SetStatus', 'widepupils', 300)
crackBaggyEffect()
else -- if canceled
exports.qbx_core:Notify('Canceled...', 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
end
end)

RegisterNetEvent('consumables:client:EcstasyBaggy', function()
if lib.progressBar({
duration = 3000,
label = 'Popping pills...',
label = locale('progress.popping_pills'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -327,14 +327,14 @@ RegisterNetEvent('consumables:client:EcstasyBaggy', function()

ecstasyEffect()
else -- if canceled
exports.qbx_core:Notify('Canceled...', 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
end
end)

RegisterNetEvent('consumables:client:oxy', function()
if lib.progressBar({
duration = 2000,
label = 'Healing...',
label = locale('progress.healing'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -355,14 +355,14 @@ RegisterNetEvent('consumables:client:oxy', function()
ClearPedBloodDamage(cache.ped)
healOxy()
else -- if canceled
exports.qbx_core:Notify('Canceled', 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
end
end)

RegisterNetEvent('consumables:client:meth', function()
if lib.progressBar({
duration = 1500,
label = 'Smoking meth...',
label = locale('progress.smoking_meth'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -384,14 +384,14 @@ RegisterNetEvent('consumables:client:meth', function()
TriggerEvent('evidence:client:SetStatus', 'agitated', 300)
methBagEffect()
else -- if canceled
exports.qbx_core:Notify('Canceled...', 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
end
end)

RegisterNetEvent('consumables:client:UseJoint', function()
if lib.progressBar({
duration = 1500,
label = 'Lighting joint...',
label = locale('progress.lighting_joint'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -408,7 +408,7 @@ RegisterNetEvent('consumables:client:UseJoint', function()
TriggerEvent('evidence:client:SetStatus', 'weedsmell', 300)
smokeWeed()
else -- if canceled
exports.qbx_core:Notify('Canceled...', 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
end
end)

Expand Down
8 changes: 4 additions & 4 deletions client/cruise.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local function TriggerCruiseControl()
if cruisedSpeed > 0 and GetVehicleCurrentGear(cache.vehicle) > 0 then

TriggerEvent('seatbelt:client:ToggleCruise')
exports.qbx_core:Notify('Cruise control enabled!', 'success')
exports.qbx_core:Notify(locale('success.cruise_control_enabled'), 'success')

CreateThread(function()
while cruisedSpeed > 0 and cache.vehicle do
Expand All @@ -42,7 +42,7 @@ local function TriggerCruiseControl()
if not turningOrBraking and speed < (cruisedSpeed - 1.5) then
cruisedSpeed = 0
TriggerEvent('seatbelt:client:ToggleCruise')
exports.qbx_core:Notify('Cruise control disabled!', 'error')
exports.qbx_core:Notify(locale('error.cruise_control_disabled'), 'error')
Wait(500)
break
end
Expand All @@ -59,7 +59,7 @@ local function TriggerCruiseControl()
if IsControlJustPressed(2, 72) then
cruisedSpeed = 0
TriggerEvent('seatbelt:client:ToggleCruise')
exports.qbx_core:Notify('Cruise control disabled!', 'error')
exports.qbx_core:Notify(locale('error.cruise_control_disabled'), 'error')
Wait(500)
break
end
Expand All @@ -76,7 +76,7 @@ RegisterCommand('togglecruise', function()
if vehicleClasses[vehicleClass] then
TriggerCruiseControl()
else
exports.qbx_core:Notify('Cruise control unavailable', 'error')
exports.qbx_core:Notify(locale('error.cruise_control_unavailable'), 'error')
end
end
end, false)
Expand Down
8 changes: 4 additions & 4 deletions client/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if not shouldAllow then return end

RegisterCommand('record', function()
StartRecording(1)
TriggerEvent('QBCore:Notify', 'Started Recording!', 'success')
exports.qbx_core:Notify(locale('success.started_recording'), 'success')
end, false)

RegisterCommand('clip', function()
Expand All @@ -23,16 +23,16 @@ end, false)

RegisterCommand('saveclip', function()
StopRecordingAndSaveClip()
TriggerEvent('QBCore:Notify', 'Saved Recording!', 'success')
exports.qbx_core:Notify(locale('success.saved_recording'), 'success')
end, false)

RegisterCommand('delclip', function()
StopRecordingAndDiscardClip()
TriggerEvent('QBCore:Notify', 'Deleted Recording!', 'error')
exports.qbx_core:Notify(locale('error.deleted_recording'), 'error')
end, false)

RegisterCommand('editor', function()
NetworkSessionLeaveSinglePlayer()
ActivateRockstarEditor()
TriggerEvent('QBCore:Notify', 'Later aligator!', 'error')
exports.qbx_core:Notify(locale('error.later_aligator'), 'error')
end, false)
7 changes: 5 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ description 'Collection of small scripts'
repository 'https://github.com/Qbox-project/qbx_smallresources'
version '1.1.0'

ox_lib 'locale'

shared_scripts {
'@ox_lib/init.lua',
'@qbx_core/modules/lib.lua',
Expand All @@ -18,8 +20,9 @@ client_scripts {
server_script 'server/*.lua'

files {
'config/client.lua',
'config/shared.lua'
'locales/*.json',
'config/client.lua',
'config/shared.lua'
}

lua54 'yes'
Expand Down
29 changes: 29 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"error": {
"canceled": "Canceled..",
"cruise_control_disabled": "Cruise control disabled",
"cruise_control_unavailable": "Cruise control unavailable",
"deleted_recording": "Deleted Recording!",
"later_aligator": "Later aligator!"
},
"success": {
"cruise_control_enabled": "Cruise control enabled",
"started_recording": "Started Recording!",
"saved_recording": "Saved Recording!"
},
"progress": {
"eating": "Eating..",
"drinking": "Drinking..",
"drinking_liquor": "Drinking liquor..",
"quick_sniff": "Quick sniff..",
"smoking_crack": "Smoking crack..",
"popping_pills": "Popping pills..",
"healing": "Healing..",
"smoking_meth": "Smoking meth..",
"lighting_joint": "Lighting joint.."
},
"info": {
"minutes": "minutes",
"seconds": "seconds.."
}
}

0 comments on commit 834c95f

Please sign in to comment.