From 4201f4a7359baed13d1ee3e3c18a4279e66e54bd Mon Sep 17 00:00:00 2001 From: nearbyplayer Date: Tue, 15 Aug 2017 22:39:52 -0400 Subject: [PATCH] Multi-language support --- __resource.lua | 8 +++- client/main.lua | 104 ++++++++++++++++++++++++------------------------ config.lua | 3 +- locales/en.lua | 32 +++++++++++++++ locales/fr.lua | 32 +++++++++++++++ server/main.lua | 16 ++++---- 6 files changed, 133 insertions(+), 62 deletions(-) create mode 100644 locales/en.lua create mode 100644 locales/fr.lua diff --git a/__resource.lua b/__resource.lua index d8e5a59d..83660fa5 100644 --- a/__resource.lua +++ b/__resource.lua @@ -3,11 +3,17 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' description 'ESX Taxi Job' client_scripts { + '@es_extended/locale.lua', + 'locales/en.lua', + 'locales/fr.lua', 'config.lua', 'client/main.lua' } server_scripts { + '@es_extended/locale.lua', + 'locales/en.lua', + 'locales/fr.lua', 'config.lua', 'server/main.lua' -} \ No newline at end of file +} diff --git a/client/main.lua b/client/main.lua index 5d5df427..13944ad3 100644 --- a/client/main.lua +++ b/client/main.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 @@ -93,8 +93,8 @@ function ClearCurrentMission() end function StartTaxiJob() - - ShowLoadingPromt('Prise de service : Taxi/Uber', 5000, 3) + + ShowLoadingPromt(_U('taking_service') .. 'Taxi/Uber', 5000, 3) ClearCurrentMission() OnJob = true @@ -102,7 +102,7 @@ function StartTaxiJob() end function StopTaxiJob() - + local playerPed = GetPlayerPed(-1) if IsPedInAnyVehicle(playerPed, false) and CurrentCustomer ~= nil then @@ -126,13 +126,13 @@ end function OpenTaxiActionsMenu() local elements = { - {label = 'Sortir Véhicule', value = 'spawn_vehicle'} + {label = _U('spawn_veh'), value = 'spawn_vehicle'} } if Config.EnablePlayerManagement and PlayerData.job ~= nil and PlayerData.job.grade_name == 'boss' then - table.insert(elements, {label = 'Retirer argent société', value = 'withdraw_society_money'}) - table.insert(elements, {label = 'Déposer argent ', value = 'deposit_money'}) - table.insert(elements, {label = 'Blanchir argent', value = 'wash_money'}) + table.insert(elements, {label = _U('remove_comp_money'), value = 'withdraw_society_money'}) + table.insert(elements, {label = _U('deposit_money'), value = 'deposit_money'}) + table.insert(elements, {label = _U('launder_money'), value = 'wash_money'}) end ESX.UI.Menu.CloseAll() @@ -173,7 +173,7 @@ function OpenTaxiActionsMenu() else - ESX.ShowNotification('Service complet : ' .. inServiceCount .. '/' .. maxInService) + ESX.ShowNotification(_U('full_service') .. inServiceCount .. '/' .. maxInService) end @@ -188,14 +188,14 @@ function OpenTaxiActionsMenu() ESX.UI.Menu.Open( 'dialog', GetCurrentResourceName(), 'withdraw_society_money_amount', { - title = 'Montant du retrait' + title = _U('withdraw_amount') }, function(data, menu) local amount = tonumber(data.value) if amount == nil then - ESX.ShowNotification('Montant invalide') + ESX.ShowNotification(_U('amount_invalid')) else menu.close() TriggerServerEvent('esx_society:withdrawMoney', 'taxi', amount) @@ -214,14 +214,14 @@ function OpenTaxiActionsMenu() ESX.UI.Menu.Open( 'dialog', GetCurrentResourceName(), 'deposit_money_amount', { - title = 'Montant du dépôt' + title = _U('deposit_amount') }, function(data, menu) local amount = tonumber(data.value) if amount == nil then - ESX.ShowNotification('Montant invalide') + ESX.ShowNotification(_U('amount_invalid')) else menu.close() TriggerServerEvent('esx_society:depositMoney', 'taxi', amount) @@ -240,14 +240,14 @@ function OpenTaxiActionsMenu() ESX.UI.Menu.Open( 'dialog', GetCurrentResourceName(), 'wash_money_amount', { - title = 'Montant à blanchir' + title = _U('launder_amount') }, function(data, menu) local amount = tonumber(data.value) if amount == nil then - ESX.ShowNotification('Montant invalide') + ESX.ShowNotification(_U('amount_invalid')) else menu.close() TriggerServerEvent('esx_society:washMoney', 'taxi', amount) @@ -267,7 +267,7 @@ function OpenTaxiActionsMenu() menu.close() CurrentAction = 'taxi_actions_menu' - CurrentActionMsg = 'Appuez sur ~INPUT_CONTEXT~ pour accéder au menu' + CurrentActionMsg = _U('press_to_open') CurrentActionData = {} end @@ -284,7 +284,7 @@ function OpenMobileTaxiActionsMenu() { title = 'Taxi', elements = { - {label = 'Facuration', value = 'billing'} + {label = _U('billing'), value = 'billing'} } }, function(data, menu) @@ -294,22 +294,22 @@ function OpenMobileTaxiActionsMenu() ESX.UI.Menu.Open( 'dialog', GetCurrentResourceName(), 'billing', { - title = 'Montant de la facture' + title = _U('invoice_amount') }, function(data, menu) local amount = tonumber(data.value) if amount == nil then - ESX.ShowNotification('Montant invalide') + ESX.ShowNotification(_U('amount_invalid')) else - + menu.close() - + local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() if closestPlayer == -1 or closestDistance > 3.0 then - ESX.ShowNotification('Aucun joueur à proximité') + ESX.ShowNotification(_U('no_players_near')) else TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_taxi', 'Taxi', amount) end @@ -346,7 +346,7 @@ AddEventHandler('esx_taxijob:hasEnteredMarker', function(zone) if zone == 'TaxiActions' then CurrentAction = 'taxi_actions_menu' - CurrentActionMsg = 'Appuez sur ~INPUT_CONTEXT~ pour accéder au menu' + CurrentActionMsg = _U('press_to_open') CurrentActionData = {} end @@ -356,7 +356,7 @@ AddEventHandler('esx_taxijob:hasEnteredMarker', function(zone) if IsPedInAnyVehicle(playerPed, false) then CurrentAction = 'delete_vehicle' - CurrentActionMsg = 'Appuez sur ~INPUT_CONTEXT~ pour ranger le véhicule' + CurrentActionMsg = _U('store_veh') CurrentActionData = {} end @@ -383,7 +383,7 @@ end) -- Create Blips Citizen.CreateThread(function() - + local blip = AddBlipForCoord(Config.Zones.TaxiActions.Pos.x, Config.Zones.TaxiActions.Pos.y, Config.Zones.TaxiActions.Pos.z) SetBlipSprite (blip, 198) @@ -401,13 +401,13 @@ end) -- Display markers Citizen.CreateThread(function() while true do - + Wait(0) - + if PlayerData.job ~= nil and PlayerData.job.name == 'taxi' then local coords = GetEntityCoords(GetPlayerPed(-1)) - + for k,v in pairs(Config.Zones) do if(v.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then DrawMarker(v.Type, 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) @@ -422,9 +422,9 @@ end) -- Enter / Exit marker events Citizen.CreateThread(function() while true do - + Wait(0) - + if PlayerData.job ~= nil and PlayerData.job.name == 'taxi' then local coords = GetEntityCoords(GetPlayerPed(-1)) @@ -467,12 +467,12 @@ Citizen.CreateThread(function() if CurrentCustomer == nil then - DrawSub('Conduisez à la recherche de ~y~passagers', 5000) + DrawSub(_U('drive_search_pass'), 5000) if IsPedInAnyVehicle(playerPed, false) and GetEntitySpeed(playerPed) > 0 then local waitUntil = GetGameTimer() + GetRandomIntInRange(1000, 120000) - + while OnJob and waitUntil > GetGameTimer() do Citizen.Wait(0) end @@ -504,7 +504,7 @@ Citizen.CreateThread(function() TaskStandStill(CurrentCustomer, standTime) - ESX.ShowNotification('Vous avez ~g~trouvé~s~ un client, conduisez jusqu\'à ce dernier') + ESX.ShowNotification(_U('customer_found')) end @@ -514,7 +514,7 @@ Citizen.CreateThread(function() if IsPedFatallyInjured(CurrentCustomer) then - ESX.ShowNotification('Votre client est ~r~inconscient~w~. Cherchez-en un autre.') + ESX.ShowNotification(_U('client_unconcious')) if DoesBlipExist(CurrentCustomerBlip) then RemoveBlip(CurrentCustomerBlip) @@ -542,7 +542,7 @@ Citizen.CreateThread(function() local playerCoords = GetEntityCoords(playerPed) local customerCoords = GetEntityCoords(CurrentCustomer) local customerDistance = GetDistanceBetweenCoords(playerCoords.x, playerCoords.y, playerCoords.z, customerCoords.x, customerCoords.y, customerCoords.z) - + if IsPedSittingInVehicle(CurrentCustomer, vehicle) then if CustomerEnteredVehicle then @@ -553,7 +553,7 @@ Citizen.CreateThread(function() TaskLeaveVehicle(CurrentCustomer, vehicle, 0) - ESX.ShowNotification('Vous êtes ~g~arrivé~s~ à destination') + ESX.ShowNotification(_U('arrive_dest')) TaskGoStraightToCoord(CurrentCustomer, TargetCoords.x, TargetCoords.y, TargetCoords.z, 1.0, -1, 0.0, 0.0) SetEntityAsMissionEntity(CurrentCustomer, false) @@ -586,9 +586,9 @@ Citizen.CreateThread(function() local msg = nil if street[2] ~= 0 and street[2] ~= nil then - msg = string.format("~w~Emmenez-moi à~y~ %s~w~, près de~y~ %s", GetStreetNameFromHashKey(street[1]),GetStreetNameFromHashKey(street[2])) + msg = string.format(_U('take_me_to_near'), GetStreetNameFromHashKey(street[1]),GetStreetNameFromHashKey(street[2])) else - msg = string.format("~w~Emmenez-moi à~y~ %s", GetStreetNameFromHashKey(street[1])) + msg = string.format(_U('take_me_to'), GetStreetNameFromHashKey(street[1])) end ESX.ShowNotification(msg) @@ -616,7 +616,7 @@ Citizen.CreateThread(function() if customerDistance <= 30.0 then if not IsNearCustomer then - ESX.ShowNotification('Vous êtes à proximité du client, approchez-vous de lui') + ESX.ShowNotification(_U('close_to_client')) IsNearCustomer = true end @@ -625,7 +625,7 @@ Citizen.CreateThread(function() if customerDistance <= 10.0 then if not CustomerIsEnteringVehicle then - + ClearPedTasksImmediately(CurrentCustomer) local seat = 0 @@ -638,7 +638,7 @@ Citizen.CreateThread(function() end TaskEnterVehicle(CurrentCustomer, vehicle, -1, seat, 2.0, 1) - + CustomerIsEnteringVehicle = true end @@ -651,7 +651,7 @@ Citizen.CreateThread(function() else - DrawSub('Veuillez remonter dans votre véhicule pour continuer la mission', 5000) + DrawSub(_U('return_to_veh'), 5000) end @@ -675,7 +675,7 @@ Citizen.CreateThread(function() DisplayHelpTextFromStringLabel(0, 0, 1, -1) if IsControlPressed(0, Keys['E']) and PlayerData.job ~= nil and PlayerData.job.name == 'taxi' and (GetGameTimer() - GUI.Time) > 300 then - + if CurrentAction == 'taxi_actions_menu' then OpenTaxiActionsMenu() end @@ -690,17 +690,17 @@ Citizen.CreateThread(function() if Config.MaxInService ~= -1 then TriggerServerEvent('esx_service:disableService', 'taxi') end - + DeleteVehicle(vehicle) else - ESX.ShowNotification('Vous ne pouvez ranger que les taxi') + ESX.ShowNotification(_U('only_taxi')) end end CurrentAction = nil GUI.Time = GetGameTimer() - + end end @@ -730,16 +730,16 @@ Citizen.CreateThread(function() if GetEntityModel(vehicle) == GetHashKey('taxi') then StartTaxiJob() else - ESX.ShowNotification('Vous devez être dans un taxi pour commencer la mission') + ESX.ShowNotification(_U('must_in_taxi')) end end else if PlayerData.job.grade >= 3 then - ESX.ShowNotification('Vous devez être dans un véhicule pour commencer la mission') + ESX.ShowNotification(_U('must_in_vehicle')) else - ESX.ShowNotification('Vous devez être dans un taxi pour commencer la mission') + ESX.ShowNotification(_U('must_in_taxi')) end end @@ -753,4 +753,4 @@ Citizen.CreateThread(function() end end -end) \ No newline at end of file +end) diff --git a/config.lua b/config.lua index 2f19dd8b..343775de 100644 --- a/config.lua +++ b/config.lua @@ -3,6 +3,7 @@ Config.DrawDistance = 100.0 Config.NPCJobEarnings = {min = 15, max = 40} Config.MaxInService = 2 Config.EnablePlayerManagement = false +Config.Locale = 'fr' Config.Zones = { @@ -121,4 +122,4 @@ Config.JobLocations = { {x = -1645.546, y = 144.571, z = 61.664}, {x = -1160.618, y = 744.418, z = 154.571}, {x = -798.09, y = 831.699, z = 204.351}, -} \ No newline at end of file +} diff --git a/locales/en.lua b/locales/en.lua new file mode 100644 index 00000000..3e1d049f --- /dev/null +++ b/locales/en.lua @@ -0,0 +1,32 @@ +Locales['en'] = { + + ['taking_service'] = 'taking service: ', + ['spawn_veh'] = 'spawn vehicle', + ['remove_comp_money'] = 'remove company money', + ['deposit_money'] = 'deposit money', + ['launder_money'] = 'launder money', + ['full_service'] = 'full service: ', + ['withdraw_amount'] = 'amount of withdrawal', + ['amount_invalid'] = 'amount invalid', + ['deposit_amount'] = 'amount to deposit', + ['launder_amount'] = 'amount to launder', + ['press_to_open'] = 'press ~INPUT_CONTEXT~ to access the menu' + ['billing'] = 'billing', + ['invoice_amount'] = 'invoice amount', + ['no_players_near'] = 'no players nearby', + ['store_veh'] = 'press ~INPUT_CONTEXT~ to store the vehicle', + ['drive_search_pass'] = 'driving in search of ~y~passengers', + ['customer_found'] = 'you have ~g~found~s~ a customer, drive until last', + ['client_unconcious'] = 'your client is ~r~unconscious~w~. Look for another one.', + ['arrive_dest'] = 'you have ~g~arrived~s~ at your destination', + ['take_me_to_near'] = '~w~Take me to~y~ %s~w~, near~y~ %s', + ['take_me_to'] = '~w~Take me to~y~ %s', + ['close_to_client'] = 'you are close to the client, get close to them', + ['return_to_veh'] = 'please return to your vehicle to continue the mission', + ['only_taxi'] = 'you can only storee taxis.', + ['must_in_taxi'] = 'you must be in a taxi to start the mission', + ['must_in_vehicle'] = 'you must be in a vehicle to begin the mission', + ['have_earned'] = 'you have earned ~g~$', + ['comp_earned'] = 'your company has earned ~g~$', + +} diff --git a/locales/fr.lua b/locales/fr.lua new file mode 100644 index 00000000..18347d4f --- /dev/null +++ b/locales/fr.lua @@ -0,0 +1,32 @@ +Locales['fr'] = { + + ['taking_service'] = 'prise de service : ', + ['spawn_veh'] = 'vortir véhicule', + ['remove_comp_money'] = 'retirer argent société', + ['deposit_money'] = 'déposer argent', + ['launder_money'] = 'blanchir argent', + ['full_service'] = 'service complet : ', + ['withdraw_amount'] = 'montant du retrait', + ['amount_invalid'] = 'montant invalide', + ['deposit_amount'] = 'montant du dépôt', + ['launder_amount'] = 'montant à blanchir', + ['press_to_open'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au menu', + ['billing'] = 'facuration', + ['invoice_amount'] = 'montant de la facture', + ['no_players_near'] = 'aucun joueur à proximité', + ['store_veh'] = 'appuyez sur ~INPUT_CONTEXT~ pour ranger le véhicule', + ['drive_search_pass'] = 'conduisez à la recherche de ~y~passagers', + ['customer_found'] = 'vous avez ~g~trouvé~s~ un client, conduisez jusqu\'à ce dernier', + ['client_unconcious'] = 'votre client est ~r~inconscient~w~. Cherchez-en un autre.', + ['arrive_dest'] = 'vous êtes ~g~arrivé~s~ à destination', + ['take_me_to_near'] = '~w~Emmenez-moi à~y~ %s~w~, près de~y~ %s', + ['take_me_to'] = '~w~Emmenez-moi à~y~ %s', + ['close_to_client'] = 'vous êtes à proximité du client, approchez-vous de lui', + ['return_to_veh'] = 'veuillez remonter dans votre véhicule pour continuer la mission', + ['only_taxi'] = 'vous ne pouvez ranger que les taxi', + ['must_in_taxi'] = 'vous devez être dans un taxi pour commencer la mission', + ['must_in_vehicle'] = 'vous devez être dans un véhicule pour commencer la mission', + ['have_earned'] = 'vous avez gagné ~g~$', + ['comp_earned'] = 'votre société a gagné ~g~$', + +} diff --git a/server/main.lua b/server/main.lua index 335362cc..e92e5745 100644 --- a/server/main.lua +++ b/server/main.lua @@ -8,7 +8,7 @@ end RegisterServerEvent('esx_taxijob:success') AddEventHandler('esx_taxijob:success', function() - + local xPlayer = ESX.GetPlayerFromId(source) local total = math.random(Config.NPCJobEarnings.min, Config.NPCJobEarnings.max); local societyAccount = nil @@ -29,16 +29,16 @@ AddEventHandler('esx_taxijob:success', function() xPlayer.addMoney(playerMoney) societyAccount.addMoney(societyMoney) - TriggerClientEvent('esx:showNotification', xPlayer.source, 'Vous avez gagné ~g~$'.. playerMoney) - TriggerClientEvent('esx:showNotification', xPlayer.source, 'Votre société a gagné ~g~$'.. societyMoney) + TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_earned') .. playerMoney) + TriggerClientEvent('esx:showNotification', xPlayer.source, _U('comp_earned') .. societyMoney) else xPlayer.addMoney(total) - TriggerClientEvent('esx:showNotification', xPlayer.source, 'Vous avez gagné ~g~$'.. total) - + TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_earned') .. total) + end - + end) TriggerEvent('esx_phone:registerCallback', function(source, phoneNumber, message, anon) @@ -55,5 +55,5 @@ TriggerEvent('esx_phone:registerCallback', function(source, phoneNumber, message end end end - -end) \ No newline at end of file + +end)