From 47af486268144fad19e277d8f5c71b3070176a8b Mon Sep 17 00:00:00 2001 From: Don Date: Sat, 19 Aug 2017 01:55:21 -0700 Subject: [PATCH] Multi-language support Currently only esx_jobs and lumberjack have been translated. --- __resource.lua | 9 +++++++- client/esx_jobs_cl.lua | 38 ++++++++++++++++---------------- config.lua | 5 +++-- jobs/lumberjack.lua | 50 +++++++++++++++++++++--------------------- locales/en.lua | 39 ++++++++++++++++++++++++++++++++ locales/fr.lua | 39 ++++++++++++++++++++++++++++++++ server/esx_jobs_sv.lua | 16 +++++++------- 7 files changed, 141 insertions(+), 55 deletions(-) create mode 100644 locales/en.lua create mode 100644 locales/fr.lua diff --git a/__resource.lua b/__resource.lua index a13546f2..f60e45be 100644 --- a/__resource.lua +++ b/__resource.lua @@ -1,9 +1,16 @@ server_scripts { '@mysql-async/lib/MySQL.lua', + '@es_extended/locale.lua', + 'locales/en.lua', + 'locales/fr.lua', + 'config.lua', 'server/esx_jobs_sv.lua' } client_scripts { + '@es_extended/locale.lua', + 'locales/en.lua', + 'locales/fr.lua', 'config.lua', 'jobs/fisherman.lua', 'jobs/fuel.lua', @@ -26,4 +33,4 @@ files { 'html/scripts/app.js', 'html/img/keys/enter.png', 'html/img/keys/return.png' -} \ No newline at end of file +} diff --git a/client/esx_jobs_cl.lua b/client/esx_jobs_cl.lua index 0f787a9c..45129934 100644 --- a/client/esx_jobs_cl.lua +++ b/client/esx_jobs_cl.lua @@ -1,10 +1,10 @@ local Keys = { - ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, - ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, + ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, + ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, - ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, + ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 @@ -68,17 +68,17 @@ end) AddEventHandler('esx_jobs:action', function(job, zone) menuIsShowed = true - if zone.Type == "cloakroom" then + if zone.Type == "cloakroom" then SendNUIMessage({ showMenu = true, menu = 'cloakroom' - }) + }) elseif zone.Type == "work" then hintToDisplay = "no hint to display" hintIsShowed = false local playerPed = GetPlayerPed(-1) if IsPedInAnyVehicle(playerPed, 0) then - TriggerEvent('esx:showNotification', 'Vous devez être à pied pour pouvoir travailler.') + TriggerEvent('esx:showNotification', _U('foot_work')) else TriggerServerEvent('esx_jobs:startWork', zone.Item) end @@ -187,7 +187,7 @@ function nextStep(gps) end Blips['delivery'] = AddBlipForCoord(gps.x, gps.y, gps.z) SetBlipRoute(Blips['delivery'], true) - TriggerEvent('esx:showNotification', 'Rendez-vous à la prochaine étape après avoir complété celle-ci.') + TriggerEvent('esx:showNotification', _U('next_point')) end end @@ -319,7 +319,7 @@ AddEventHandler('esx_jobs:spawnJobVehicle', function(spawnPoint, vehicle) table.insert(myPlate, plate) plate = string.gsub(plate, " ", "") TriggerEvent('esx_vehiclelock:updatePlayerCars', "add", plate) - SetVehRadioStation(veh, "OFF") + SetVehRadioStation(veh, "OFF") TaskWarpPedIntoVehicle(playerPed, veh, -1) isJobVehicleDestroyed = false @@ -360,10 +360,10 @@ Citizen.CreateThread(function() local coords = GetEntityCoords(GetPlayerPed(-1)) for k,v in pairs(zones) do if onDuty or v.Type == "cloakroom" or PlayerData.job.name == "reporter" then - if(v.Marker ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then + if(v.Marker ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then DrawMarker(v.Marker, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, true, 2, false, false, false, false) end - end + end end end end @@ -375,16 +375,16 @@ Citizen.CreateThread(function() Wait(0) local coords = GetEntityCoords(GetPlayerPed(-1)) for k,v in pairs(Config.PublicZones) do - if(v.Marker ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then + if(v.Marker ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then DrawMarker(v.Marker, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, true, 2, false, false, false, false) - end + end end end end) -- Activate public marker Citizen.CreateThread(function() - while true do + while true do Wait(0) local coords = GetEntityCoords(GetPlayerPed(-1)) local position = nil @@ -420,7 +420,7 @@ end) -- Activate menu when player is inside marker Citizen.CreateThread(function() - while true do + while true do Wait(0) if PlayerData.job ~= nil and PlayerData.job.name ~= 'unemployed' then @@ -473,20 +473,20 @@ Citizen.CreateThread(function() for i=1, #myPlate, 1 do Citizen.Trace(myPlate[i]) if (myPlate[i] == plate) and (playerPed == driverPed) then - hintToDisplay = zone.Hint .. "\n" .. "La caution rendue sera de ~g~" .. cautionVehicleInCaseofDrop .. "$~s~." + hintToDisplay = zone.Hint .. "\n" .. _U('security_deposit') .. cautionVehicleInCaseofDrop .. "~s~." isVehicleOwner = true break end end if not isVehicleOwner then - hintToDisplay = "Ce n'est pas votre véhicule ou vous devez être conducteur." + hintToDisplay = _U('not_your_vehicle') end else - hintToDisplay = "Vous devez être dans un véhicule." + hintToDisplay = _U('in_vehicle') end hintIsShowed = true elseif onDuty and zone.Spawner ~= spawner then - hintToDisplay = "Vous n'êtes pas au bon point de livraison." + hintToDisplay = _U('wrong_point') hintIsShowed = true else if not isInPublicMarker then @@ -558,4 +558,4 @@ Citizen.CreateThread(function() SendNUIMessage({ move = 'DOWN' }) end end -end) \ No newline at end of file +end) diff --git a/config.lua b/config.lua index fe37a95a..89682111 100644 --- a/config.lua +++ b/config.lua @@ -1,5 +1,6 @@ Config = {} Config.DrawDistance = 1000.0 +Config.Locale = 'fr' Config.Plates = { taxi = "TAXI", @@ -17,7 +18,7 @@ Config.Plates = { Config.Jobs = {} -Config.PublicZones = { +Config.PublicZones = { EnterBuilding = { Pos = { x = -118.21381378174, y = -607.14227294922, z = 35.280723571777 }, Size = {x = 3.0, y = 3.0, z = 0.2}, @@ -41,4 +42,4 @@ Config.PublicZones = { Hint = "Appuyez sur ~INPUT_PICKUP~ pour aller à l'entrée de l'immeuble.", Teleport = { x = -113.07, y = -604.93, z = 35.28 }, }, -} \ No newline at end of file +} diff --git a/jobs/lumberjack.lua b/jobs/lumberjack.lua index 07a0f96d..4ecaead1 100644 --- a/jobs/lumberjack.lua +++ b/jobs/lumberjack.lua @@ -18,9 +18,9 @@ Config.Jobs.lumberjack = { Color = {r = 204, g = 204, b = 0}, Marker= 1, Blip = true, - Name = "Vestiaire", + Name = _U('lj_cr_title'), Type = "cloakroom", - Hint = "Appuyez sur ~INPUT_PICKUP~ pour vous changer." + Hint = _U('lj_cloakroom') }, Wood = { @@ -29,11 +29,11 @@ Config.Jobs.lumberjack = { Color = {r = 204, g = 204, b = 0}, Marker= 1, Blip = true, - Name = "Tas de bois", + Name = _U('lj_mapblip'), Type = "work", Item = { { - name = "Bois", + name = _U('lj_wood'), db_name= "wood", time = 3000, max = 20, @@ -44,7 +44,7 @@ Config.Jobs.lumberjack = { drop = 100 } }, - Hint = "Appuyez sur ~INPUT_PICKUP~ pour récupérer du bois." + Hint = _U('lj_pickup') }, CuttedWood = { @@ -53,22 +53,22 @@ Config.Jobs.lumberjack = { Color = {r = 204, g = 204, b = 0}, Marker= 1, Blip = false, - Name = "Découpe du bois", + Name = _U('lj_cutwood'), Type = "work", Item = { { - name = "Bois coupé", + name = _U('lj_cutwood'), db_name= "cutted_wood", time = 5000, max = 20, add = 1, remove = 1, requires = "wood", - requires_name = "Bois", + requires_name = _U('lj_wood'), drop = 100 } }, - Hint = "Appuyez sur ~INPUT_PICKUP~ pour couper du bois." + Hint = _U('lj_cutwood_button') }, Planks = { @@ -77,22 +77,22 @@ Config.Jobs.lumberjack = { Color = {r = 204, g = 204, b = 0}, Marker= 1, Blip = false, - Name = "Planches", + Name = _U('lj_board'), Type = "work", Item = { { - name = "Paquet de planche", + name = _U('lj_planks'), db_name= "packaged_plank", time = 4000, max = 100, add = 5, remove = 1, requires = "cutted_wood", - requires_name = "Bois coupé", + requires_name = _U('lj_cutwood'), drop = 100 } }, - Hint = "Appuyez sur ~INPUT_PICKUP~ pour récupérer des planches." + Hint = _U('lj_pick_boards') }, VehicleSpawner = { @@ -101,10 +101,10 @@ Config.Jobs.lumberjack = { Color = {r = 204, g = 204, b = 0}, Marker= 1, Blip = false, - Name = "Spawner véhicule de fonction", + Name = _U('lj_spawn_veh'), Type = "vehspawner", Spawner = 1, - Hint = "Appuyez sur ~INPUT_PICKUP~ pour appeler le véhicule de livraison.", + Hint = _U('lj_spawn_veh_button'), Caution = 2000 }, @@ -113,21 +113,21 @@ Config.Jobs.lumberjack = { Size = {x = 3.0, y = 3.0, z = 1.0}, Marker= -1, Blip = false, - Name = "Véhicule de fonction", + Name = _U('lj_service_vh'), Type = "vehspawnpt", Spawner = 1, Heading = 285.1 }, - + VehicleDeletePoint = { Pos = {x = 1216.8983154297, y = -1229.2396240234, z = 34.403507232666}, Size = {x = 5.0, y = 5.0, z = 1.0}, Color = {r = 255, g = 0, b = 0}, Marker= 1, Blip = false, - Name = "Supression du véhicule", + Name = _U('lj_return_vh'), Type = "vehdelete", - Hint = "Appuyez sur ~INPUT_PICKUP~ pour rendre le véhicule.", + Hint = _U('lj_return_vh_button'), Spawner = 1, Caution = 2000, GPS = 0, @@ -140,22 +140,22 @@ Config.Jobs.lumberjack = { Size = {x = 5.0, y = 5.0, z = 3.0}, Marker= 1, Blip = true, - Name = "Point de livraison", - Type = "delivery", + Name = _U('lj_delivery_point'), + Type = "delivery", Spawner = 1, Item = { { - name = "Livraison", + name = _U('lj_delivery'), time = 500, remove = 1, max = 100, -- if not present, probably an error at itemQtty >= item.max in esx_jobs_sv.lua price = 13, requires = "packaged_plank", - requires_name = "Paquet de planche", + requires_name = _U('lj_planks'), drop = 100 } }, - Hint = "Appuyez sur ~INPUT_PICKUP~ pour livrer les planches." + Hint = _U('lj_deliver_button') } } -} \ No newline at end of file +} diff --git a/locales/en.lua b/locales/en.lua new file mode 100644 index 00000000..04403eb9 --- /dev/null +++ b/locales/en.lua @@ -0,0 +1,39 @@ +Locales['en'] = { + --Global menus + ['bank_deposit'] = 'a security deposit of ~g~', + ['bank_deposit_r'] = 'a security deposit of ~g~$', + ['bank_deposit2'] = '$ ~s~was made to you after your fainting.', + ['bank_nodeposit'] = "you did not have a surety", + ['foot_work'] = 'you have to be on foot to be able to work.', + ['next_point'] = 'go to the next step after completing this one.', + ['security_deposit'] = 'the security given will be ~g~$', + ['not_your_vehicle'] = "this is not your vehicle or you must be a driver.", + ['in_vehicle'] = 'you must be in a vehicle.', + ['wrong_point'] = "you are not at the right point of delivery.", + ['max_limit'] = 'you have the maximum: ', + ['not_enough'] = "you do not have enough", + ['not_enough2'] = ' to continue this task.', + ['caution_taken'] = ' ~s~was taken from you.', + ['caution_returned'] = ' ~s~was returned to you.', + + --Lumber Jack job + ['lj_cr_title'] = 'cloakroom', + ['lj_cloakroom'] = 'press ~INPUT_PICKUP~ to change clothes.', + ['lj_mapblip'] = 'wood pile', + ['lj_wood'] = 'wood', + ['lj_pickup'] = 'press ~INPUT_PICKUP~ to retrieve wood.', + ['lj_cutwood'] = 'cutting wood', + ['lj_cutwood_button'] = 'press ~INPUT_PICKUP~ to cut wood.', + ['lj_board'] = 'boards', + ['lj_planks'] = 'board package', + ['lj_delivery'] = 'delivery', + ['lj_cutwood'] = 'wood cut', + ['lj_pick_boards'] = 'press ~INPUT_PICKUP~ to retrieve boards.', + ['lj_spawn_veh'] = 'spawn vehicle', + ['lj_spawn_veh_button'] = 'press ~INPUT_PICKUP~ to call the delivery vehicle.', + ['lj_service_vh'] = 'service vehicle', + ['lj_return_vh'] = 'return vehicle', + ['lj_delivery_point'] = 'delivery point', + ['lj_return_vh_button'] = 'press ~INPUT_PICKUP~ to return the vehicle.', + ['lj_deliver_button'] = 'press ~INPUT_PICKUP~ to deliver the boards.' +} diff --git a/locales/fr.lua b/locales/fr.lua new file mode 100644 index 00000000..3bbe4dcb --- /dev/null +++ b/locales/fr.lua @@ -0,0 +1,39 @@ +Locales['fr'] = { + --Global menus + ['bank_deposit'] = 'une caution de ~g~', + ['bank_deposit_r'] = 'une caution de ~g~$', + ['bank_deposit2'] = '$ ~s~vous a été rendue suite à votre évanouissment.', + ['bank_nodeposit'] = "vous n'aviez pas de caution", + ['foot_work'] = 'vous devez être à pied pour pouvoir travailler.', + ['next_point'] = 'rendez-vous à la prochaine étape après avoir complété celle-ci.', + ['security_deposit'] = 'la caution rendue sera de ~g~$', + ['not_your_vehicle'] = "ce n'est pas votre véhicule ou vous devez être conducteur.", + ['in_vehicle'] = 'vous devez être dans un véhicule.', + ['wrong_point'] = "vous n'êtes pas au bon point de livraison.", + ['max_limit'] = 'vous avez le maximum de: ', + ['not_enough'] = "vous n'avez plus assez de", + ['not_enough2'] = ' pour continuer cette tâche.', + ['caution_taken'] = ' ~s~vous a été prélevée.', + ['caution_returned'] = ' ~s~vous a été rendue.', + + --Lumber Jack job + ['lj_cr_title'] = 'vestiaire', + ['lj_cloakroom'] = 'appuyez sur ~INPUT_PICKUP~ pour vous changer.', + ['lj_mapblip'] = 'tas de bois', + ['lj_wood'] = 'bois', + ['lj_pickup'] = 'appuyez sur ~INPUT_PICKUP~ pour récupérer du bois.', + ['lj_cutwood'] = 'découpe du bois', + ['lj_cutwood_button'] = 'appuyez sur ~INPUT_PICKUP~ pour couper du bois.', + ['lj_board'] = 'planches', + ['lj_planks'] = 'paquet de planche', + ['lj_delivery'] = 'livraison', + ['lj_cutwood'] = 'bois coupé', + ['lj_pick_boards'] = 'appuyez sur ~INPUT_PICKUP~ pour récupérer des planches.', + ['lj_spawn_veh'] = 'spawner véhicule de fonction', + ['lj_spawn_veh_button'] = 'appuyez sur ~INPUT_PICKUP~ pour appeler le véhicule de livraison.', + ['lj_service_vh'] = 'véhicule de fonction', + ['lj_return_vh'] = 'supression du véhicule', + ['lj_delivery_point'] = 'Point de livraison', + ['lj_return_vh_button'] = 'appuyez sur ~INPUT_PICKUP~ pour rendre le véhicule.', + ['lj_deliver_button'] = 'appuyez sur ~INPUT_PICKUP~ pour livrer les planches.' +} diff --git a/server/esx_jobs_sv.lua b/server/esx_jobs_sv.lua index 2cec943a..f47c4a56 100644 --- a/server/esx_jobs_sv.lua +++ b/server/esx_jobs_sv.lua @@ -38,9 +38,9 @@ AddEventHandler('esx_jobs:giveBackCautionInCaseOfDrop', function() if caution > 0 then xPlayer.addAccountMoney('bank', value) - TriggerClientEvent('esx:showNotification', _source, 'Une caution de ~g~'.. value .. '$ ~s~vous a été rendue suite à votre évanouissment.') + TriggerClientEvent('esx:showNotification', _source, _U('bank_deposit_g').. value .. _U('bank_deposit2')) else - TriggerClientEvent('esx:showNotification', _source, "Vous n'aviez pas de caution") + TriggerClientEvent('esx:showNotification', _source, _U('bank_nodeposit')) end end) @@ -53,7 +53,7 @@ local function Work(source, item) for i=1, #item, 1 do local itemQtty = 0 - if item[i].name ~= "Livraison" then + if item[i].name ~= _U('lj_delivery') then itemQtty = xPlayer.getInventoryItem(item[i].db_name).count end @@ -62,10 +62,10 @@ local function Work(source, item) requiredItemQtty = xPlayer.getInventoryItem(item[1].requires).count end - if item[i].name ~= "Livraison" and itemQtty >= item[i].max then - TriggerClientEvent('esx:showNotification', source, 'Vous avez le maximum de: ' .. item[i].name) + if item[i].name ~= _U('lj_delivery') and itemQtty >= item[i].max then + TriggerClientEvent('esx:showNotification', source, _U('max_limit') .. item[i].name) elseif item[i].requires ~= "nothing" and requiredItemQtty <= 0 then - TriggerClientEvent('esx:showNotification', source, "Vous n'avez plus assez de " .. item[1].requires_name .. " pour continuer cette tâche.") + TriggerClientEvent('esx:showNotification', source, _U('not_enough') .. item[1].requires_name .. _U('not_enough2')) else if item[i].name ~= "Livraison" then -- Chances to drop the item @@ -116,11 +116,11 @@ AddEventHandler('esx_jobs:caution', function(cautionType, cautionAmount, spawnPo if cautionType == "take" then xPlayer.removeAccountMoney('bank', cautionAmount) xPlayer.set('caution', cautionAmount) - TriggerClientEvent('esx:showNotification', source, 'Une caution de ~r~'.. cautionAmount .. '$ ~s~vous a été prélevée.') + TriggerClientEvent('esx:showNotification', source, _U('bank_deposit_r') .. cautionAmount .. _U('caution_taken')) TriggerClientEvent('esx_jobs:spawnJobVehicle', source, spawnPoint, vehicle) elseif cautionType == "give_back" then xPlayer.addAccountMoney('bank', cautionAmount) xPlayer.set('caution', 0) - TriggerClientEvent('esx:showNotification', source, 'Une caution de ~g~'.. cautionAmount .. '$ ~s~vous a été rendue.') + TriggerClientEvent('esx:showNotification', source, _U('bank_deposit_g') .. cautionAmount .. _U('caution_returned')) end end)