Skip to content

Commit

Permalink
feat(locale): use ox_lib locales (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
solareon authored Jul 2, 2024
1 parent 9566886 commit f571406
Show file tree
Hide file tree
Showing 34 changed files with 785 additions and 893 deletions.
2 changes: 1 addition & 1 deletion client/damage/damage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ local function checkForDamage()
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0 },
multiline = false,
args = { Lang:t('info.status'), WEAPONS[weaponHash].damagereason }
args = { locale('info.status'), WEAPONS[weaponHash].damagereason }
})
WeaponsThatDamagedPlayer[weaponHash] = true
end
Expand Down
6 changes: 3 additions & 3 deletions client/dead.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ end)
---@param weapon string weapon hash
local function logDeath(victim, attacker, weapon)
local playerId = NetworkGetPlayerIndexFromPed(victim)
local playerName = (' %s (%d)'):format(GetPlayerName(playerId), GetPlayerServerId(playerId)) or Lang:t('info.self_death')
local playerName = (' %s (%d)'):format(GetPlayerName(playerId), GetPlayerServerId(playerId)) or locale('info.self_death')
local killerId = NetworkGetPlayerIndexFromPed(attacker)
local killerName = ('%s (%d)'):format(GetPlayerName(killerId), GetPlayerServerId(killerId)) or Lang:t('info.self_death')
local killerName = ('%s (%d)'):format(GetPlayerName(killerId), GetPlayerServerId(killerId)) or locale('info.self_death')
local weaponLabel = WEAPONS[weapon]?.label or 'Unknown'
local weaponName = WEAPONS[weapon]?.name or 'Unknown'
local message = Lang:t('logs.death_log_message', { killername = killerName, playername = playerName, weaponlabel = weaponLabel, weaponname = weaponName })
local message = locale('logs.death_log_message', killerName, playerName, weaponLabel, weaponName)

lib.callback.await('qbx_medical:server:log', false, 'logDeath', message)
end
Expand Down
10 changes: 5 additions & 5 deletions client/laststand.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ local function logPlayerKiller()
end

local killerId = NetworkGetPlayerIndexFromPed(killer)
local killerName = killerId ~= -1 and (' %s (%d)'):format(GetPlayerName(killerId), GetPlayerServerId(killerId)) or Lang:t('info.self_death')
local killerName = killerId ~= -1 and (' %s (%d)'):format(GetPlayerName(killerId), GetPlayerServerId(killerId)) or locale('info.self_death')
local weaponItem = WEAPONS[killerWeapon]
local weaponLabel = Lang:t('info.wep_unknown') or (weaponItem and weaponItem.label)
local weaponName = Lang:t('info.wep_unknown') or (weaponItem and weaponItem.name)
local message = Lang:t('logs.death_log_message', { killername = killerName, playername = GetPlayerName(cache.playerId), weaponlabel = weaponLabel, weaponname = weaponName })
local weaponLabel = locale('info.wep_unknown') or (weaponItem and weaponItem.label)
local weaponName = locale('info.wep_unknown') or (weaponItem and weaponItem.name)
local message = locale('logs.death_log_message', killerName, GetPlayerName(cache.playerId), weaponLabel, weaponName)

lib.callback.await('qbx_medical:server:log', false, 'playerKiller', message)
end
Expand All @@ -51,7 +51,7 @@ local function countdownLastStand()
if LaststandTime - 1 > 0 then
LaststandTime -= 1
else
exports.qbx_core:Notify(Lang:t('error.bled_out'), 'error')
exports.qbx_core:Notify(locale('error.bled_out'), 'error')
EndLastStand()
logPlayerKiller()
DeathTime = config.deathTime
Expand Down
10 changes: 5 additions & 5 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ local function doLimbAlert()
local i = 0
for bodyPartKey, injury in pairs(Injuries) do
local bodyPart = sharedConfig.bodyParts[bodyPartKey]
limbDamageMsg = limbDamageMsg .. Lang:t('info.pain_message', { limb = bodyPart.label, severity = sharedConfig.woundLevels[injury.severity].label})
limbDamageMsg = limbDamageMsg .. locale('info.pain_message', bodyPart.label, sharedConfig.woundLevels[injury.severity].label)
i += 1
if i < NumInjuries then
limbDamageMsg = limbDamageMsg .. ' | '
end
end
else
limbDamageMsg = Lang:t('info.many_places')
limbDamageMsg = locale('info.many_places')
end
exports.qbx_core:Notify(limbDamageMsg, 'error')
end
Expand Down Expand Up @@ -173,7 +173,7 @@ end
---notify the player of bleeding to their body.
function SendBleedAlert()
if DeathState == sharedConfig.deathState.DEAD or BleedLevel == 0 then return end
exports.qbx_core:Notify(Lang:t('info.bleed_alert', {bleedstate = sharedConfig.bleedingStates[BleedLevel]}), 'inform')
exports.qbx_core:Notify(locale('info.bleed_alert', sharedConfig.bleedingStates[BleedLevel]), 'inform')
end

exports('SendBleedAlert', SendBleedAlert)
Expand All @@ -199,7 +199,7 @@ lib.callback.register('qbx_medical:client:heal', function(type)
else
resetMinorInjuries()
end
exports.qbx_core:Notify(Lang:t('success.wounds_healed'), 'success')
exports.qbx_core:Notify(locale('success.wounds_healed'), 'success')
end)

CreateThread(function()
Expand All @@ -226,6 +226,6 @@ RegisterNetEvent('qbx_medical:client:playerRevived', function()
resetAllInjuries()
ResetPedMovementClipset(cache.ped, 0.0)
TriggerServerEvent('hud:server:RelieveStress', 100)
exports.qbx_core:Notify(Lang:t('info.healthy'), 'inform')
exports.qbx_core:Notify(locale('info.healthy'), 'inform')
LocalPlayer.state.invBusy = false
end)
46 changes: 23 additions & 23 deletions config/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ return {
woundLevels = {
{
movementRate = 0.98,
label = Lang:t('states.irritated'),
label = locale('states.irritated'),
},
{
movementRate = 0.96,
label = Lang:t('states.quite_painful'),
label = locale('states.quite_painful'),
},
{
movementRate = 0.94,
label = Lang:t('states.painful'),
label = locale('states.painful'),
},
{
movementRate = 0.92,
label = Lang:t('states.really_painful'),
label = locale('states.really_painful'),
},
},

bleedingStates = { -- Translate bleeding alerts
Lang:t('states.little_bleed'),
Lang:t('states.bleed'),
Lang:t('states.lot_bleed'),
Lang:t('states.big_bleed'),
locale('states.little_bleed'),
locale('states.bleed'),
locale('states.lot_bleed'),
locale('states.big_bleed'),
},

---@alias BodyPartKey string
Expand All @@ -33,21 +33,21 @@ return {

---@type table<BodyPartKey, BodyPart>
bodyParts = {
HEAD = { label = Lang:t('body.head'), causeLimp = false },
NECK = { label = Lang:t('body.neck'), causeLimp = false },
SPINE = { label = Lang:t('body.spine'), causeLimp = true },
UPPER_BODY = { label = Lang:t('body.upper_body'), causeLimp = false },
LOWER_BODY = { label = Lang:t('body.lower_body'), causeLimp = true },
LARM = { label = Lang:t('body.left_arm'), causeLimp = false, },
LHAND = { label = Lang:t('body.left_hand'), causeLimp = false, },
LFINGER = { label = Lang:t('body.left_fingers'), causeLimp = false, },
LLEG = { label = Lang:t('body.left_leg'), causeLimp = true, },
LFOOT = { label = Lang:t('body.left_foot'), causeLimp = true, },
RARM = { label = Lang:t('body.right_arm'), causeLimp = false, },
RHAND = { label = Lang:t('body.right_hand'), causeLimp = false, },
RFINGER = { label = Lang:t('body.right_fingers'), causeLimp = false, },
RLEG = { label = Lang:t('body.right_leg'), causeLimp = true, },
RFOOT = { label = Lang:t('body.right_foot'), causeLimp = true, },
HEAD = { label = locale('body.head'), causeLimp = false },
NECK = { label = locale('body.neck'), causeLimp = false },
SPINE = { label = locale('body.spine'), causeLimp = true },
UPPER_BODY = { label = locale('body.upper_body'), causeLimp = false },
LOWER_BODY = { label = locale('body.lower_body'), causeLimp = true },
LARM = { label = locale('body.left_arm'), causeLimp = false, },
LHAND = { label = locale('body.left_hand'), causeLimp = false, },
LFINGER = { label = locale('body.left_fingers'), causeLimp = false, },
LLEG = { label = locale('body.left_leg'), causeLimp = true, },
LFOOT = { label = locale('body.left_foot'), causeLimp = true, },
RARM = { label = locale('body.right_arm'), causeLimp = false, },
RHAND = { label = locale('body.right_hand'), causeLimp = false, },
RFINGER = { label = locale('body.right_fingers'), causeLimp = false, },
RLEG = { label = locale('body.right_leg'), causeLimp = true, },
RFOOT = { label = locale('body.right_foot'), causeLimp = true, },
},

---@enum DeathState
Expand Down
6 changes: 3 additions & 3 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ description 'qbx_medical'
repository 'https://github.com/Qbox-project/qbx_medical'
version '1.0.0'

ox_lib 'locale'

shared_scripts {
'@ox_lib/init.lua',
'@qbx_core/shared/locale.lua',
'locales/en.lua',
'locales/*.lua',
'shared/**/*.lua',
}

Expand All @@ -30,6 +29,7 @@ server_scripts {
}

files {
'locales/*.json',
'config/client.lua',
'config/shared.lua',
}
Expand Down
53 changes: 53 additions & 0 deletions locales/ar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"error": {
"bled_out": "لقد نزفت"
},
"success": {
"wounds_healed": "لقد التئمت جروحك"
},
"info": {
"self_death": "قتل نفسه او قتله سكان اصلي",
"wep_unknown": "غير معروف",
"status": "فحص الحالة",
"healthy": "أنت بصحة جيدة مرة أخرى",
"pain_message": "%s %s",
"many_places": "لديك ألم في أماكن كثيرة",
"bleed_alert": "%s انت",
"revive_player_a": "إحياء لاعب أو نفسك (المسؤول فقط)",
"player_id": "معرف اللاعب (قد يكون فارغا)",
"pain_level": "قم بتعيين مستوى الألم الخاص بك أو مستوى اللاعبين (المسؤول فقط)",
"kill": "اقتل لاعبًا أو قتل نفسك (المسؤول فقط)",
"heal_player_a": "شفاء لاعب أو نفسك (المسؤول فقط)"
},
"states": {
"irritated": "منزعج",
"quite_painful": "مؤلم جدا",
"painful": "مؤلم",
"really_painful": "مؤلم حقا",
"little_bleed": "ينزف قليلا",
"bleed": "نزيف",
"lot_bleed": "ينزف كثيرا",
"big_bleed": "ينزف كثيرا"
},
"body": {
"head": "رأس",
"neck": "رقبه",
"spine": "العمود الفقري",
"upper_body": "الجزء العلوي",
"lower_body": "الجسم السفلي",
"left_arm": "الذراع الأيسر",
"left_hand": "اليد اليسرى",
"left_fingers": "الأصابع اليسرى",
"left_leg": "الساق اليسرى",
"left_foot": "القدم اليسرى",
"right_arm": "الذراع الأيمن",
"right_hand": "اليد اليمنى",
"right_fingers": "الاصابع اليمنى",
"right_leg": "الساق اليمنى",
"right_foot": "القدم اليمنى"
},
"logs": {
"death_log_title": "%s (%s) ميت",
"death_log_message": "%s قتل %s ب **%s** (%s)"
}
}
61 changes: 0 additions & 61 deletions locales/ar.lua

This file was deleted.

53 changes: 53 additions & 0 deletions locales/cs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"error": {
"bled_out": "Vykrvácel(a) jsi..."
},
"success": {
"wounds_healed": "Tvá zranění byla uzdravena!"
},
"info": {
"self_death": "Sami sebe nebo NPC",
"wep_unknown": "Neznámý",
"status": "Kontrola stavu",
"healthy": "Jsi opět zcela zdravý(á)!",
"pain_message": "Tvůj %s cítí %s",
"many_places": "Máš bolest na mnoha místech...",
"bleed_alert": "Krvácíš %s",
"revive_player_a": "Oživit hráče nebo sebe (pouze pro administrátory)",
"player_id": "ID hráče (může být prázdné)",
"pain_level": "Nastavit úroveň bolesti pro sebe nebo hráče (pouze pro administrátory)",
"kill": "Zabít hráče nebo sebe (pouze pro administrátory)",
"heal_player_a": "Uzdravit hráče nebo sebe (pouze pro administrátory)"
},
"states": {
"irritated": "podrážděný(á)",
"quite_painful": "docela bolestivý(á)",
"painful": "bolestivý(á)",
"really_painful": "opravdu bolestivý(á)",
"little_bleed": "krev trochu uniká...",
"bleed": "krev uniká...",
"lot_bleed": "krev uniká hodně...",
"big_bleed": "krev uniká velmi mnoho..."
},
"body": {
"head": "Hlava",
"neck": "Krk",
"spine": "Hřbet",
"upper_body": "Horní část těla",
"lower_body": "Dolní část těla",
"left_arm": "Levá ruka",
"left_hand": "Levá ruka",
"left_fingers": "Levé prsty",
"left_leg": "Levá noha",
"left_foot": "Levá noha",
"right_arm": "Pravá ruka",
"right_hand": "Pravá ruka",
"right_fingers": "Pravé prsty",
"right_leg": "Pravá noha",
"right_foot": "Pravá noha"
},
"logs": {
"death_log_title": "%s (%s) je mrtvý(á)",
"death_log_message": "%s zabil(a) %s s **%s** (%s)"
}
}
Loading

0 comments on commit f571406

Please sign in to comment.