From 8bdae162074ff85442c9f958599c26f8a910499e Mon Sep 17 00:00:00 2001 From: Alexert Date: Mon, 4 Dec 2023 20:30:13 +0100 Subject: [PATCH 1/3] added locale --- client/main.lua | 8 +++-- client/management.lua | 50 +++++++++++++-------------- client/parking.lua | 42 +++++++++++------------ client/wardrobe.lua | 18 +++++----- fxmanifest.lua | 1 + locales/en.json | 80 +++++++++++++++++++++++++++++++++++++++++++ locales/it.json | 79 ++++++++++++++++++++++++++++++++++++++++++ server/main.lua | 3 +- server/management.lua | 12 +++---- server/parking.lua | 46 ++++++++++++------------- server/wardrobe.lua | 6 ++-- 11 files changed, 253 insertions(+), 92 deletions(-) create mode 100644 locales/en.json create mode 100644 locales/it.json diff --git a/client/main.lua b/client/main.lua index 8529b43..1c22015 100644 --- a/client/main.lua +++ b/client/main.lua @@ -8,6 +8,8 @@ CurrentZone = nil ---@type table local componentActions = {} +lib.locale() + ---@param componentType string ---@param action function ---@param actionPermissions string[] @@ -19,7 +21,7 @@ exports('registerComponentAction', RegisterComponentAction) RegisterComponentAction('stash', function(component) return exports.ox_inventory:openInventory('stash', component.name) -end, {'All access'}) +end, {locale('all_access')}) local menus = { contextMenu = { @@ -50,6 +52,7 @@ local function setBlipVariables(blip, property) local variables = PropertyVariables[property] SetBlipColour(blip, variables.colour) SetBlipShrink(blip, true) + SetBlipDisplay(blip, 4) if variables.owner ~= player.charId and not (variables.group and player.groups[variables.group]) then SetBlipAsShortRange(blip, true) @@ -301,14 +304,13 @@ local function isPermitted(property, componentId) for i = 1, #variables.permissions do local level = variables.permissions[i] local access = i == 1 and 1 or level.components[componentId] - if access and (level.everyone or (level.players and level.players[player.charId]) or player.hasGroup(level.groups)) then return access end end end - lib.notify({title = 'Permission Denied', type = 'error'}) + lib.notify({title = locale("permissions_deined"), type = 'error'}) return false end exports('isPermitted', isPermitted) diff --git a/client/management.lua b/client/management.lua index 8ee4b2d..b0420f0 100644 --- a/client/management.lua +++ b/client/management.lua @@ -36,27 +36,27 @@ RegisterComponentAction('management', function(component) local property = Properties[component.property] local variables = PropertyVariables[property.name] - local values = {'Edit Component Access', 'Edit Door Access', 'Edit Members', 'Delete Level'} + local values = {locale("edit_componet_access"), locale("edit_door_acces"), locale("edit_menbers"), locale("delete_level")} local options = { { - label = ('Owner: %s'):format(variables.ownerName or 'None'), - description = 'Set Property Owner' + label = locale("owner", variables.ownerName or locale("none")), + description = locale("set_property_owner") }, { - label = ('Group: %s'):format(variables.groupName or 'None'), - description = 'Set Property Group' + label = locale("group", variables.ownerName or locale("none")), + description = locale("set_property_group") } } for i = 1, #variables.permissions do options[#options + 1] = { - label = ('Level %s'):format(i), + label = locale("level",i), values = values } end options[#options + 1] = { - label = 'Create New Level', + label = locale("create_new_level"), } return { @@ -66,15 +66,15 @@ RegisterComponentAction('management', function(component) local level = scrollIndex and selected - 2 or #variables.permissions + 1 local permissionLevel = variables.permissions[level] - local title = values[scrollIndex] or 'New Level' + local title = values[scrollIndex] or locale("new_level") if scrollIndex then local options = { - {label = ('Save Level %s'):format(level)} + {label = locale("save_level",level)} } if level == 1 and scrollIndex ~= 3 then - lib.notify({title = 'Action not possible for this permission level', type = 'error'}) + lib.notify({title =locale("action_not_possible_for_level"), type = 'error'}) lib.showMenu('component_menu') return elseif scrollIndex == 1 then @@ -85,7 +85,7 @@ RegisterComponentAction('management', function(component) label = component.name, values = {'None', table.unpack(Permissions[component.type])}, defaultIndex = permissionLevel.components and permissionLevel.components[i] and permissionLevel.components[i] + 1 or 1, - description = ('Type: %s'):format(component.type:gsub('^%l', string.upper)), + description = locale("type", component.type:gsub('^%l', string.upper)), close = false, args = { section = 'components', @@ -109,7 +109,7 @@ RegisterComponentAction('management', function(component) end elseif scrollIndex == 3 then options[#options + 1] = { - label = 'Everyone', + label = locale("everyone"), checked = permissionLevel.everyone or false, close = false, args = {section = 'everyone'} @@ -145,8 +145,8 @@ RegisterComponentAction('management', function(component) end elseif scrollIndex == 4 then local delete = lib.alertDialog({ - header = 'Please Confirm', - content = 'Are you sure you want to delete this permission level?', + header = locale("please_confirm"), + content = locale("are_you_sure_delete_permission_level"), centered = true, cancel = true }) @@ -228,14 +228,14 @@ RegisterComponentAction('management', function(component) lib.registerMenu({ id = 'set_property_value', - title = ('Set Property %s'):format(value:gsub('^%l', string.upper)), + title = locale("set_property",value:gsub('^%l', string.upper)), options = options, onClose = onClose }, function(selected, scrollIndex, args) local setValue = lib.alertDialog({ - header = 'Please Confirm', - content = ('Are you sure you want to set the property %s to %s'):format(value, args.label), + header = locale("please_confirm"), + content = locale("are_you_sure_set_property", value, args.label), centered = true, cancel = true }) @@ -257,7 +257,7 @@ RegisterComponentAction('management', function(component) lib.showMenu('set_property_value') else local options = { - {label = ('Continue Level %s'):format(level)} + {label = locale("continue_level", level)} } for i = 1, #property.components do local component = property.components[i] @@ -265,7 +265,7 @@ RegisterComponentAction('management', function(component) options[#options + 1] = { label = component.name, values = {'None', table.unpack(Permissions[component.type])}, - description = ('Type: %s'):format(component.type:gsub('^%l', string.upper)), + description = locale("type", component.type:gsub('^%l', string.upper)), close = false, args = { section = 'components', @@ -276,14 +276,14 @@ RegisterComponentAction('management', function(component) lib.registerMenu({ id = 'new_level_components', - title = 'Set Component Access', + title = locale("set_component_access"), options = options, onSideScroll = updatePermissionData, onClose = onClose }, function(selected, scrollIndex, args) local options = { - {label = ('Continue Level %s'):format(level)} + {label = locale("continue_level", level)} } for i = 1, #displayData.doors do local door = displayData.doors[i] @@ -301,7 +301,7 @@ RegisterComponentAction('management', function(component) lib.registerMenu({ id = 'new_level_doors', - title = 'Set Door Access', + title = locale("set_door_access"), options = options, onSideScroll = updatePermissionData, onCheck = updatePermissionData, @@ -309,11 +309,11 @@ RegisterComponentAction('management', function(component) }, function(selected, scrollIndex, args) local options = { - {label = ('Finish Level %s'):format(level)} + {label = locale ("finish_level", level)} } options[#options + 1] = { - label = 'Everyone', + label = locale("everyone"), checked = false, close = false, args = {section = 'everyone'} @@ -349,7 +349,7 @@ RegisterComponentAction('management', function(component) lib.registerMenu({ id = 'new_level_members', - title = 'Set Members', + title = locale("set_members"), options = options, onSideScroll = updatePermissionData, onCheck = updatePermissionData, diff --git a/client/parking.lua b/client/parking.lua index 51ad06f..01e6a97 100644 --- a/client/parking.lua +++ b/client/parking.lua @@ -21,7 +21,7 @@ local function manageVehicle(data) } }, { - title = 'Update Values', + title = locale("update_values"), disabled = data.vehicle.owner ~= player.charId, onSelect = function(args) local groupTable = player.groups @@ -34,18 +34,18 @@ local function manageVehicle(data) local options = { { type = 'input', - label = 'Label', + label = locale("label_label"), default = data.vehicle.label }, { type = 'select', - label = 'Group', + label = locale("label_group"), default = data.vehicle.group, options = groups } } - local input = lib.inputDialog('Update Vehicle Values', options) + local input = lib.inputDialog(locale("update_vehicle_values"), options) if input then if not data.vehicle.label and input[1] == "" then input[1] = nil end @@ -72,14 +72,13 @@ local function manageVehicle(data) end, }, { - title = 'Retrieve', + title = locale("retrive"), onSelect = function(args) local response, msg = lib.callback.await('ox_property:parking', 100, 'retrieve_vehicle', { property = data.component.property, componentId = data.component.componentId, id = data.vehicle.id }) - if msg then lib.notify({title = msg, type = response and 'success' or 'error'}) end @@ -89,7 +88,7 @@ local function manageVehicle(data) lib.registerContext({ id = 'manage_vehicle', - title = 'Manage Vehicle', + title = locale("manage_vehicle"), menu = 'vehicle_list', options = options }) @@ -112,15 +111,16 @@ local function vehicleList(data) ['Location'] = vehicle.location }, onSelect = function(args) - if args.action == 'Manage' then + if args.action == locale("manage") then manageVehicle({component = data.component, vehicle = vehicle}) else - local response, msg = lib.callback.await('ox_property:parking', 100, args.action == 'Retrieve' and 'retrieve_vehicle' or 'move_vehicle', { + print(json.encode(args,{indent=true})) + local response, msg = lib.callback.await('ox_property:parking', 100, args.action == locale('retrive') and 'retrieve_vehicle' or 'move_vehicle', { property = data.component.property, componentId = data.component.componentId, id = args.id }) - + if msg then lib.notify({title = msg, type = response and 'success' or 'error'}) end @@ -135,7 +135,7 @@ local function vehicleList(data) lib.registerContext({ id = 'vehicle_list', - title = data.componentOnly and ('%s - %s - Vehicles'):format(Properties[data.component.property].label, data.component.name) or 'All Vehicles', + title = data.componentOnly and locale("vehicle_list", Properties[data.component.property].label, data.component.name) or locale("all_vehicles"), menu = 'component_menu', options = options }) @@ -157,7 +157,7 @@ RegisterComponentAction('parking', function(component) if cache.seat == -1 then options[#options + 1] = { - title = 'Store Vehicle', + title = locale("store_vehicle"), onSelect = function() if cache.seat == -1 then local response, msg = lib.callback.await('ox_property:parking', 100, 'store_vehicle', { @@ -170,7 +170,7 @@ RegisterComponentAction('parking', function(component) lib.notify({title = msg, type = response and 'success' or 'error'}) end else - lib.notify({title = "You are not in the driver's seat", type = 'error'}) + lib.notify({title = locale("are_you_not_driver_seat"), type = 'error'}) end end } @@ -182,13 +182,13 @@ RegisterComponentAction('parking', function(component) for i = 1, len do local vehicle = vehicles[i] vehicle.name = vehicleNames[vehicle.model] - vehicle.location = 'Unknown' - vehicle.action = 'Recover' + vehicle.location = locale("unknown") + vehicle.action = locale("recover") if vehicle.stored and vehicle.stored:find(':') then if vehicle.stored == currentComponent then - vehicle.location = 'Current location' - vehicle.action = vehicle.owner == player.charId and 'Manage' or 'Retrieve' + vehicle.location = locale("current_location") + vehicle.action = vehicle.owner == player.charId and locale("manage") or locale("retrive") componentVehicles[#componentVehicles + 1] = vehicle else local propertyName, componentId = string.strsplit(':', vehicle.stored) @@ -204,8 +204,8 @@ RegisterComponentAction('parking', function(component) end options[#options + 1] = { - title = 'Open Location', - description = 'View your vehicles at this location', + title = locale("open_location"), + description = locale("view_vehicles_at_location"), metadata = {['Vehicles'] = #componentVehicles}, onSelect = #componentVehicles > 0 and vehicleList, args = { @@ -216,8 +216,8 @@ RegisterComponentAction('parking', function(component) } options[#options + 1] = { - title = 'All Vehicles', - description = 'View all your vehicles', + title = locale("all_vehicles"), + description = locale("view_all_vehicles"), metadata = {['Vehicles'] = len}, onSelect = len > 0 and vehicleList, args = { diff --git a/client/wardrobe.lua b/client/wardrobe.lua index eb00833..47191ef 100644 --- a/client/wardrobe.lua +++ b/client/wardrobe.lua @@ -14,7 +14,7 @@ RegisterComponentAction('wardrobe', function(component) if component.outfits then options[#options + 1] = { - title = 'Zone wardrobe', + title = locale("zone_wardrobe"), event = 'ox_property:outfits', args = { property = component.property, @@ -25,7 +25,7 @@ RegisterComponentAction('wardrobe', function(component) } options[#options + 1] = { - title = 'Save new zone outfit', + title = locale("save_new_zone_outfit"), arrow = true, event = 'ox_property:saveOutfit', args = { @@ -39,7 +39,7 @@ RegisterComponentAction('wardrobe', function(component) end options[#options + 1] = { - title = 'Personal wardrobe', + title = locale("personal_wardrobe"), event = 'ox_property:outfits', args = { property = component.property, @@ -49,7 +49,7 @@ RegisterComponentAction('wardrobe', function(component) } options[#options + 1] = { - title = 'Save new personal outfit', + title = locale("save_new_personal_outfit"), arrow = true, event = 'ox_appearance:saveOutfit', args = {slot = 'new', name = ''} @@ -61,7 +61,7 @@ end, {'All access'}) local function checkCurrentZone(data) if CurrentZone?.property == data.property and CurrentZone?.componentId == data.componentId then return true end - lib.notify({title = 'Zone Mismatch', type = 'error'}) + lib.notify({title = locale("zone_mismatch"), type = 'error'}) return false end exports('checkCurrentZone', checkCurrentZone) @@ -86,7 +86,7 @@ RegisterNetEvent('ox_property:outfits', function(data) local menu = { id = 'zone_wardrobe', - title = data.zoneOutfits and ('%s - %s - Wardrobe'):format(CurrentZone.property, CurrentZone.name) or 'Personal Wardrobe', + title = data.zoneOutfits and locale("wardrobe_list", CurrentZone.property, CurrentZone.name) or locale("personal_wardrobe"), menu = 'component_menu', options = options } @@ -104,7 +104,7 @@ AddEventHandler('ox_property:setOutfit', function(data) menu = 'zone_wardrobe', options = { { - title = 'Wear', + title = locale("wear"), onSelect = function(args) local data, msg = lib.callback.await('ox_property:wardrobe', 100, 'apply_outfit', { property = args.property, @@ -126,7 +126,7 @@ AddEventHandler('ox_property:setOutfit', function(data) } }, { - title = 'Update', + title = locale("update"), event = 'ox_property:saveOutfit', args = { property = CurrentZone.property, @@ -164,7 +164,7 @@ AddEventHandler('ox_property:saveOutfit', function(data) TriggerServerEvent('ox_property:saveOutfit', data, appearance) end else - local input = lib.inputDialog(('Update %s'):format(data.name), {'Outfit Name (leave blank to delete)'}) + local input = lib.inputDialog(locale("diaolog_update_title",data.name), {locale("dialog_update_input")}) local appearance = exports['fivem-appearance']:getPedAppearance(cache.ped) data.outfitNames[data.slot] = input?[1] diff --git a/fxmanifest.lua b/fxmanifest.lua index 197c7e9..c737b00 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -45,6 +45,7 @@ ox_libs { } files { + 'locales/*.json', '/data/**' } diff --git a/locales/en.json b/locales/en.json new file mode 100644 index 0000000..b167f7b --- /dev/null +++ b/locales/en.json @@ -0,0 +1,80 @@ +{ + "all_access":"All Access", + "none":"None", + "permission_denied":"Permission Denied", + "edit_component_access":"Edit Component Access", + "edit_door_acces":"Edit Door Access", + "edit_members":"Edit Members", + "delete_level":"Delete Level", + "owner":"Owner: %s", + "group":"Group: %s", + "set_property_owner":"Set Property Owner", + "set_property_group":"Set Property Group", + "level":"Level: %s", + "create_new_level":"Create New Level", + "new_level":"New Level", + "save_level":"Save level %s", + "action_not_possible_for_level":"Action not possible for this permission level", + "type":"Type: %s", + "everyone":"Everyone", + "please_confirm":"Please confirm", + "are_you_sure_delete_permission_level":"Are you sure you want to delete this permission level?", + "set_property":"Set Property: %s", + "are_you_sure_set_property":"Are you sure you want to set the property %s to %s ?", + "continue_level":"Continue Level: %s", + "set_compontent_access":"Set Component Access", + "set_door_access":"Set Door Access", + "finish_level":"Finish Level %s", + "set_members":"Set Members", + "update_values":"Update Values", + "label_label":"Label", + "label_group":"Group", + "update_vehicle_values":"Update Vehicle Values", + "retrive":"Retrive", + "manage_vehicle":"Manage Vehicle", + "vehicle_list" : "%s - %s - Vehicles", + "all_vehicles":"All Vehicles", + "store_vehicle":"Store Vehicle", + "are_you_not_driver_seat": "You are not in the driver's seat", + "unknown":"Unknown", + "recover":"Recover", + "move":"Move", + "current_location":"Current Location", + "manage":"Manage", + "open_location":"Open Location", + "view_vehicles_at_location":"View your vehicles at this location", + "view_all_vehicles":"View all your vehicles", + "zone_wardrobe":"Zone Wardrobe", + "save_new_zone_outfit":"Save new zone outfit", + "personal_wardrobe":"Personal Wardrobe", + "save_new_personal_outfit":"Save new personal outfit", + "zone_mismatch":"Zone Mismatch", + "wardrobe_list":"%s - %s - Wardrobe", + "wear":"Wear", + "update":"Update", + "diaolog_update_title":"Update %s", + "dialog_update_input":"Outfit Name (leave blank to delete)", + "transacrion_failed":"Transaction Failed", + "permission_level_updated":"Permission Level Updated", + "action_not_allowed":"Action not allowed", + "permission_level_deleted":"Permission Level Deleted", + "property_value_set": "Property Value Set", + "not_permitted": "Not Permitted", + "invalid_action": "Invalid Action", + "vehicle_not_found": "Vehicle Not Found", + "component_mismatch": "Component Mismatch", + "vehicle_updated": "Vehicle Updated", + "not_vehicle_owner": "Not Vehicle Owner", + "vehicle_requirements_not_met": "Vehicle Requirements Not Met", + "vehicle_stored": "Vehicle Stored", + "spawn_not_found": "Spawn Not Found", + "vehicle_retrieved": "Vehicle Retrieved", + "vehicle_cannot_be_modified_while_displayed": "Vehicle Cannot Be Modified While Displayed", + "vehicle_in_use": "Vehicle In Use", + "model_not_found": "Model Not Found", + "outfit_saved": "Outfit Saved", + "vehicle_moved": "Vehicle Moved", + "vehicle_recovered": "Vehicle Recovered", + "permissions_deined": "Permissions Denied", + "":"" +} \ No newline at end of file diff --git a/locales/it.json b/locales/it.json new file mode 100644 index 0000000..299ecda --- /dev/null +++ b/locales/it.json @@ -0,0 +1,79 @@ +{ + "all_access": "Tutti gli accessi", + "none": "Nessuno", + "permission_denied": "Permesso negato", + "edit_component_access": "Modifica accesso al componente", + "edit_door_acces": "Modifica accesso alla porta", + "edit_members": "Modifica membri", + "delete_level": "Elimina livello", + "owner": "Proprietario: %s", + "group": "Gruppo: %s", + "set_property_owner": "Imposta proprietario della proprietà", + "set_property_group": "Imposta gruppo della proprietà", + "level": "Livello: %s", + "create_new_level": "Crea nuovo livello", + "new_level": "Nuovo livello", + "save_level": "Salva livello %s", + "action_not_possible_for_level": "Azione non possibile per questo livello di permesso", + "type": "Tipo: %s", + "everyone": "Tutti", + "please_confirm": "Conferma", + "are_you_sure_delete_permission_level": "Sei sicuro di voler eliminare questo livello di permesso?", + "set_property": "Imposta proprietà: %s", + "are_you_sure_set_property": "Sei sicuro di voler impostare la proprietà %s su %s?", + "continue_level": "Continua livello: %s", + "set_compontent_access": "Imposta accesso al componente", + "set_door_access": "Imposta accesso alla porta", + "finish_level": "Completa livello %s", + "set_members": "Imposta membri", + "update_values": "Aggiorna valori", + "label_label": "Etichetta", + "label_group": "Gruppo", + "update_vehicle_values": "Aggiorna valori veicolo", + "retrive": "Recupera", + "manage_vehicle": "Gestisci veicolo", + "vehicle_list": "%s - %s - Veicoli", + "all_vehicles": "Tutti i veicoli", + "store_vehicle": "Archivia veicolo", + "are_you_not_driver_seat": "Non sei seduto al posto del conducente", + "unknown": "Sconosciuto", + "recover": "Recupera", + "current_location": "Posizione attuale", + "manage": "Gestisci", + "open_location": "Apri posizione", + "view_vehicles_at_location": "Visualizza i tuoi veicoli in questa posizione", + "view_all_vehicles": "Visualizza tutti i tuoi veicoli", + "zone_wardrobe": "Armadio zona", + "save_new_zone_outfit": "Salva nuovo outfit di zona", + "personal_wardrobe": "Armadio personale", + "save_new_personal_outfit": "Salva nuovo outfit personale", + "zone_mismatch": "Incompatibilità zona", + "wardrobe_list": "%s - %s - Armadio", + "wear": "Indossa", + "update": "Aggiorna", + "diaolog_update_title": "Aggiorna %s", + "dialog_update_input": "Nome outfit (lascia vuoto per eliminare)", + "transacrion_failed":"Transazione Fallita", + "permission_level_updated":"Livello di Permesso Aggiornato", + "action_not_allowed":"Azione non consentita", + "permission_level_deleted":"Livello di Permesso Eliminato", + "property_value_set": "Valore della Proprietà Impostato", + "not_permitted": "Non Consentito", + "invalid_action": "Azione non valida", + "vehicle_not_found": "Veicolo non trovato", + "component_mismatch": "Incompatibilità Componente", + "vehicle_updated": "Veicolo Aggiornato", + "not_vehicle_owner": "Non Proprietario del Veicolo", + "vehicle_requirements_not_met": "Requisiti del Veicolo non Soddisfatti", + "vehicle_stored": "Veicolo Archiviato", + "spawn_not_found": "Spawn non trovato", + "vehicle_retrieved": "Veicolo Recuperato", + "vehicle_cannot_be_modified_while_displayed": "Il Veicolo non può essere modificato mentre è visualizzato", + "vehicle_in_use": "Veicolo in Uso", + "model_not_found": "Modello non trovato", + "outfit_saved": "Outfit Salvato", + "vehicle_moved": "Veicolo Spostato", + "vehicle_recovered": "Veicolo Recuperato", + "permissions_deined": "Permesso Negato", + "": "" + } diff --git a/server/main.lua b/server/main.lua index 9d145c4..af33cc6 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,5 +1,6 @@ ---@type table Properties = {} +lib.locale() exports('getPropertyData', function(property, componentId) return componentId and Properties[property].components[componentId] or Properties[property] @@ -247,6 +248,6 @@ function Transaction(source, msg, data) return true end - return false, 'transaction_failed' + return false, locale('transaction_failed') end exports('transaction', Transaction) diff --git a/server/management.lua b/server/management.lua index 152ee34..60b7dc8 100644 --- a/server/management.lua +++ b/server/management.lua @@ -156,7 +156,7 @@ local function updatePermissionLevel(property, data) updateProperty(property) end - return true, 'permission_level_updated' + return true, locale('permission_level_updated') end ---@param property OxPropertyObject @@ -164,7 +164,7 @@ end ---@return boolean response, string msg local function deletePermissionLevel(property, level) if level == 1 then - return false, 'action_not_allowed' + return false, locale("action_not_allowed") end table.remove(property.permissions, level) @@ -173,7 +173,7 @@ local function deletePermissionLevel(property, level) updateProperty(property) - return true, 'permission_level_deleted' + return true, locale("permission_level_deleted") end ---@param property OxPropertyObject @@ -206,7 +206,7 @@ local function setPropertyValue(property, data) updateProperty(property) - return true, 'property_value_set' + return true, locale("property_value_set") end ---@param source integer @@ -217,7 +217,7 @@ lib.callback.register('ox_property:management', function(source, action, data) local permitted, msg = IsPermitted(source, data.property, data.componentId, 'management') if not permitted or permitted > 1 then - return false, msg or 'not_permitted' + return false, msg or locale("not_permitted") end if action == 'get_data' then @@ -233,5 +233,5 @@ lib.callback.register('ox_property:management', function(source, action, data) return setPropertyValue(property, data) end - return false, 'invalid_action' + return false, locale("invalid_action") end) diff --git a/server/parking.lua b/server/parking.lua index 510e0e2..041e4a2 100644 --- a/server/parking.lua +++ b/server/parking.lua @@ -37,9 +37,9 @@ local function setVehicleValues(player, data) local vehicle = MySQL.single.await('SELECT JSON_VALUE(data, "$.label") AS `label`, `group`, `stored` FROM `vehicles` WHERE `id` = ? AND `owner` = ?', {data.id, player.charId}) if not vehicle then - return false, 'vehicle_not_found' + return false, locale('vehicle_not_found') elseif vehicle.stored ~= ('%s:%s'):format(data.property, data.componentId) then - return false, 'component_mismatch' + return false, locale("component_mismatch") end for key, value in pairs(data.values) do @@ -51,8 +51,7 @@ local function setVehicleValues(player, data) end end end - - return true, 'vehicle_updated' + return true, locale("vehicle_updated") end exports('setVehicleValues', setVehicleValues) @@ -98,14 +97,14 @@ local function storeVehicle(player, component, properties) player = type(player) == 'number' and Ox.GetPlayer(player) or player --[[@as OxPlayer]] local vehicle = Ox.GetVehicle(GetVehiclePedIsIn(player.ped, false)) if not vehicle then - return false, 'vehicle_not_found' + return false, locale("vehicle_not_found") elseif player.charId ~= vehicle.owner or (vehicle.group and not player.hasGroup(vehicle.group)) then - return false, 'not_vehicle_owner' + return false, locale("not_vehicle_owner") end vehicle.data = vehicleData[vehicle.model] if not component.vehicles[vehicle.data.type] then - return false, 'vehicle_requirements_not_met' + return false, locale("vehicle_requirements_not_met") end clearVehicleOfPassengers({entity = vehicle.entity, seats = vehicle.data.seats}) @@ -113,7 +112,7 @@ local function storeVehicle(player, component, properties) vehicle.set('properties', properties) vehicle.setStored(('%s:%s'):format(component.property, component.componentId), true) - return true, 'vehicle_stored' + return true, locale("vehicle_stored") end exports('storeVehicle', storeVehicle) @@ -124,24 +123,23 @@ exports('storeVehicle', storeVehicle) local function retrieveVehicle(player, component, id) player = type(player) == 'number' and Ox.GetPlayer(player) or player --[[@as OxPlayer]] local vehicle = MySQL.single.await('SELECT `model`, `stored` FROM `vehicles` WHERE `id` = ? AND (`owner` = ? OR `group` IN (?))', {id, player.charId, getPlayerGroupsArray(player)}) - if not vehicle then - return false, 'vehicle_not_found' + return false, locale("vehicle_not_found") elseif vehicle.stored ~= ('%s:%s'):format(component.property, component.componentId) then - return false, 'component_mismatch' + return false, locale("component_mismatch") end local spawn = lib.callback.await('ox_property:findClearSpawn', player.source) if not spawn then - return false, 'spawn_not_found' + return false, locale("spawn_not_found") elseif not component.vehicles[vehicleData[vehicle.model].type] then - return false, 'vehicle_requirements_not_met' + return false, locale("vehicle_requirements_not_met") end Ox.CreateVehicle(id, spawn.coords, spawn.heading) - return true, 'vehicle_retrieved' + return true, locale("vehicle_retrieved") end exports('retrieveVehicle', retrieveVehicle) @@ -158,13 +156,13 @@ local function moveVehicle(player, property, component, id) local veh = vehicles[i] if veh.id == id then if veh.stored == 'displayed' then - return false, 'vehicle_cannot_be_modified_while_displayed' + return false, locale("vehicle_cannot_be_modified_while_displayed") end local seats = vehicleData[veh.model].seats for j = -1, seats - 1 do if GetPedInVehicleSeat(veh.entity, j) ~= 0 then - return false, 'vehicle_in_use' + return false, locale("vehicle_in_use") end end @@ -178,9 +176,9 @@ local function moveVehicle(player, property, component, id) vehicle = MySQL.single.await('SELECT `model`, `stored` FROM `vehicles` WHERE `id` = ? AND (`owner` = ? OR `group` IN (?))', {id, player.charId, getPlayerGroupsArray(player)}) if not vehicle then - return false, 'vehicle_not_found' + return false, locale("vehicle_not_found") elseif vehicle.stored == 'displayed' then - return false, 'vehicle_cannot_be_modified_while_displayed' + return false, locale("vehicle_cannot_be_modified_while_displayed") end recover = not vehicle.stored or not vehicle.stored:find(':') @@ -189,13 +187,13 @@ local function moveVehicle(player, property, component, id) local vehData = vehicleData[vehicle.model] if not vehData then - return false, 'model_not_found' + return false, locale("model_not_found") elseif not component.vehicles[vehData.type] then - return false, 'vehicle_requirements_not_met' + return false, locale("vehicle_requirements_not_met") end if property.owner ~= player.charId then - local response, msg = Transaction(player.source, (recover and '%s Recovery' or '%s Move'):format(vehData.name), { + local response, msg = Transaction(player.source, (recover and '%s '..locale("recover") or '%s '..locale("move")):format(vehData.name), { amount = recover and 1000 or 500, from = {name = player.name, identifier = player.charId}, to = {name = property.groupName or property.ownerName, identifier = property.group or property.owner} @@ -212,7 +210,7 @@ local function moveVehicle(player, property, component, id) vehicle.setStored(('%s:%s'):format(property.name, component.componentId), true) end - return true, recover and 'vehicle_recovered' or 'vehicle_moved' + return true, recover and locale("vehicle_recovered") or locale("vehicle_moved") end ---@param source integer @@ -224,7 +222,7 @@ lib.callback.register('ox_property:parking', function(source, action, data) local permitted, msg = IsPermitted(player, data.property, data.componentId, 'parking') if not permitted or permitted > 1 then - return false, msg or 'not_permitted' + return false, msg or locale("not_permitted") end if action == 'get_vehicles' then @@ -243,5 +241,5 @@ lib.callback.register('ox_property:parking', function(source, action, data) return moveVehicle(player, property, component, data.id) end - return false, 'invalid_action' + return false, locale("invalid_action") end) diff --git a/server/wardrobe.lua b/server/wardrobe.lua index 8f99afc..14a22d7 100644 --- a/server/wardrobe.lua +++ b/server/wardrobe.lua @@ -4,7 +4,7 @@ lib.callback.register('ox_property:wardrobe', function(source, action, data) local permitted, msg = IsPermitted(source, data.property, data.componentId, 'wardrobe') if not permitted or permitted > 1 then - return false, msg or 'not_permitted' + return false, msg or locale("not_permitted") end if action == 'get_outfits' then @@ -15,10 +15,10 @@ lib.callback.register('ox_property:wardrobe', function(source, action, data) elseif action == 'save_outfit' then ox_appearance:saveOutfit(('%s:%s'):format(data.property, data.componentId), data.appearance, data.slot, data.outfitNames) - return true, 'outfit_saved' + return true, locale("outfit_saved") elseif action == 'apply_outfit' then return ox_appearance:loadOutfit(('%s:%s'):format(data.property, data.componentId), data.slot) end - return false, 'invalid_action' + return false, locale("invalid_action") end) From 0dd1debab7f815450e21ea9d02b66ba2c060c5e3 Mon Sep 17 00:00:00 2001 From: Alexert Date: Mon, 4 Dec 2023 20:53:31 +0100 Subject: [PATCH 2/3] fix(locale): retrive fix --- locales/it.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/it.json b/locales/it.json index 299ecda..f49f75d 100644 --- a/locales/it.json +++ b/locales/it.json @@ -30,7 +30,7 @@ "label_label": "Etichetta", "label_group": "Gruppo", "update_vehicle_values": "Aggiorna valori veicolo", - "retrive": "Recupera", + "retrive": "Ritira", "manage_vehicle": "Gestisci veicolo", "vehicle_list": "%s - %s - Veicoli", "all_vehicles": "Tutti i veicoli", From 493e255b1515f9f0a58aa3c97408144c9082c062 Mon Sep 17 00:00:00 2001 From: Alexert Date: Tue, 5 Dec 2023 08:04:07 +0100 Subject: [PATCH 3/3] feat: added missing locale all_access --- client/management.lua | 2 +- client/parking.lua | 2 +- client/wardrobe.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/management.lua b/client/management.lua index b0420f0..dc12b10 100644 --- a/client/management.lua +++ b/client/management.lua @@ -378,6 +378,6 @@ RegisterComponentAction('management', function(component) end end }, 'listMenu' -end, {'All access'}) +end, {locale('all_access')}) RegisterMenu({'edit_level', 'set_property_value', 'new_level_components', 'new_level_doors', 'new_level_members'}, 'listMenu') diff --git a/client/parking.lua b/client/parking.lua index 01e6a97..0718205 100644 --- a/client/parking.lua +++ b/client/parking.lua @@ -227,7 +227,7 @@ RegisterComponentAction('parking', function(component) } return {options = options}, 'contextMenu' -end, {'All access'}) +end, {locale('all_access')}) RegisterMenu({'vehicle_list', 'manage_vehicle'}, 'contextMenu') diff --git a/client/wardrobe.lua b/client/wardrobe.lua index 47191ef..24e9e9d 100644 --- a/client/wardrobe.lua +++ b/client/wardrobe.lua @@ -56,7 +56,7 @@ RegisterComponentAction('wardrobe', function(component) } return {options = options}, 'contextMenu' -end, {'All access'}) +end, {locale('all_access')}) local function checkCurrentZone(data) if CurrentZone?.property == data.property and CurrentZone?.componentId == data.componentId then return true end