Skip to content

Commit

Permalink
feat: ox locales
Browse files Browse the repository at this point in the history
  • Loading branch information
Swellington-Soares authored Oct 4, 2024
1 parent bde367b commit 5edbd2a
Show file tree
Hide file tree
Showing 22 changed files with 330 additions and 370 deletions.
60 changes: 30 additions & 30 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CreateThread(function()
SetBlipAsShortRange(blip, true)
SetBlipColour(blip, 5)
BeginTextCommandSetBlipName('STRING')
AddTextComponentSubstringPlayerName(Lang:t('info.title'))
AddTextComponentSubstringPlayerName(locale('info.title'))
EndTextCommandSetBlipName(blip)
end
end)
Expand Down Expand Up @@ -50,10 +50,10 @@ CreateThread(function()
onEnter = function()
lib.registerContext({
id = 'open_pawnShopMain',
title = Lang:t('info.title'),
title = locale('info.title'),
options = {
{
title = Lang:t('info.open_pawn'),
title = locale('info.open_pawn'),
event = 'qb-pawnshop:client:openMenu'
}
}
Expand All @@ -73,8 +73,8 @@ RegisterNetEvent('qb-pawnshop:client:openMenu', function()
if GetClockHours() >= config.timeOpen and GetClockHours() <= config.timeClosed then
local pawnShop = {
{
title = Lang:t('info.sell'),
description = Lang:t('info.sell_pawn'),
title = locale('info.sell'),
description = locale('info.sell_pawn'),
event = 'qb-pawnshop:client:openPawn',
args = {
items = config.pawnItems
Expand All @@ -83,8 +83,8 @@ RegisterNetEvent('qb-pawnshop:client:openMenu', function()
}
if not isMelting then
pawnShop[#pawnShop + 1] = {
title = Lang:t('info.melt'),
description = Lang:t('info.melt_pawn'),
title = locale('info.melt'),
description = locale('info.melt_pawn'),
event = 'qb-pawnshop:client:openMelt',
args = {
items = config.meltingItems
Expand All @@ -93,7 +93,7 @@ RegisterNetEvent('qb-pawnshop:client:openMenu', function()
end
if canTake then
pawnShop[#pawnShop + 1] = {
title = Lang:t('info.melt_pickup'),
title = locale('info.melt_pickup'),
serverEvent = 'qb-pawnshop:server:pickupMelted',
args = {
items = meltedItem
Expand All @@ -102,18 +102,18 @@ RegisterNetEvent('qb-pawnshop:client:openMenu', function()
end
lib.registerContext({
id = 'open_pawnShop',
title = Lang:t('info.title'),
title = locale('info.title'),
options = pawnShop
})
lib.showContext('open_pawnShop')
else
exports.qbx_core:Notify(Lang:t('info.pawn_closed', { value = config.timeOpen, value2 = config.timeClosed }))
exports.qbx_core:Notify(locale('info.pawn_closed', config.timeOpen, config.timeClosed ))
end
else
local pawnShop = {
{
title = Lang:t('info.sell'),
description = Lang:t('info.sell_pawn'),
title = locale('info.sell'),
description = locale('info.sell_pawn'),
event = 'qb-pawnshop:client:openPawn',
args = {
items = config.pawnItems
Expand All @@ -122,8 +122,8 @@ RegisterNetEvent('qb-pawnshop:client:openMenu', function()
}
if not isMelting then
pawnShop[#pawnShop + 1] = {
title = Lang:t('info.melt'),
description = Lang:t('info.melt_pawn'),
title = locale('info.melt'),
description = locale('info.melt_pawn'),
event = 'qb-pawnshop:client:openMelt',
args = {
items = config.meltingItems
Expand All @@ -132,7 +132,7 @@ RegisterNetEvent('qb-pawnshop:client:openMenu', function()
end
if canTake then
pawnShop[#pawnShop + 1] = {
title = Lang:t('info.melt_pickup'),
title = locale('info.melt_pickup'),
serverEvent = 'qb-pawnshop:server:pickupMelted',
args = {
items = meltedItem
Expand All @@ -141,7 +141,7 @@ RegisterNetEvent('qb-pawnshop:client:openMenu', function()
end
lib.registerContext({
id = 'open_pawnShop',
title = Lang:t('info.title'),
title = locale('info.title'),
options = pawnShop
})
lib.showContext('open_pawnShop')
Expand All @@ -158,7 +158,7 @@ RegisterNetEvent('qb-pawnshop:client:openPawn', function(data)
if v.name == data.items[i].item then
pawnMenu[#pawnMenu + 1] = {
title = exports.ox_inventory:Items()[v.name].label,
description = Lang:t('info.sell_items', { value = data.items[i].price }),
description = locale('info.sell_items', data.items[i].price ),
event = 'qb-pawnshop:client:pawnitems',
args = {
label = exports.ox_inventory:Items()[v.name].label,
Expand All @@ -173,7 +173,7 @@ RegisterNetEvent('qb-pawnshop:client:openPawn', function(data)
lib.registerContext({
id = 'open_pawnMenu',
menu = 'open_pawnShop',
title = Lang:t('info.title'),
title = locale('info.title'),
options = pawnMenu
})
lib.showContext('open_pawnMenu')
Expand All @@ -190,7 +190,7 @@ RegisterNetEvent('qb-pawnshop:client:openMelt', function(data)
if v.name == data.items[i].item then
meltMenu[#meltMenu + 1] = {
title = exports.ox_inventory:Items()[v.name].label,
description = Lang:t('info.melt_item', { value = exports.ox_inventory:Items()[v.name].label }),
description = locale('info.melt_item', exports.ox_inventory:Items()[v.name].label ),
event = 'qb-pawnshop:client:meltItems',
args = {
label = exports.ox_inventory:Items()[v.name].label,
Expand All @@ -206,42 +206,42 @@ RegisterNetEvent('qb-pawnshop:client:openMelt', function(data)
lib.registerContext({
id = 'open_meltMenu',
menu = 'open_pawnShop',
title = Lang:t('info.title'),
title = locale('info.title'),
options = meltMenu
})
lib.showContext('open_meltMenu')
end)
end)

RegisterNetEvent('qb-pawnshop:client:pawnitems', function(item)
local sellingItem = lib.inputDialog(Lang:t('info.title'), {
local sellingItem = lib.inputDialog(locale('info.title'), {
{
type = 'number',
label = 'amount',
placeholder = Lang:t('info.max', { value = item.amount })
placeholder = locale('info.max', item.amount )
}
})
if sellingItem then
if not sellingItem[1] or sellingItem[1] <= 0 then return end
TriggerServerEvent('qb-pawnshop:server:sellPawnItems', item.name, sellingItem[1], item.price)
else
exports.qbx_core:Notify(Lang:t('error.negative'), 'error')
exports.qbx_core:Notify(locale('error.negative'), 'error')
end
end)

RegisterNetEvent('qb-pawnshop:client:meltItems', function(item)
local meltingItem = lib.inputDialog(Lang:t('info.melt'), {
local meltingItem = lib.inputDialog(locale('info.melt'), {
{
type = 'number',
label = 'amount',
placeholder = Lang:t('info.max', { value = item.amount })
placeholder = locale('info.max', item.amount )
}
})
if meltingItem then
if not meltingItem[1] or meltingItem[1] <= 0 then return end
TriggerServerEvent('qb-pawnshop:server:meltItemRemove', item.name, meltingItem[1], item)
else
exports.qbx_core:Notify(Lang:t('error.no_melt'), 'error')
exports.qbx_core:Notify(locale('error.no_melt'), 'error')
end
end)

Expand All @@ -260,13 +260,13 @@ RegisterNetEvent('qb-pawnshop:client:startMelting', function(item, meltingAmount
table.insert(meltedItem, { item = item, amount = meltingAmount })
if config.sendMeltingEmail then
TriggerServerEvent('qb-phone:server:sendNewMail', {
sender = Lang:t('info.title'),
subject = Lang:t('info.subject'),
message = Lang:t('info.message'),
sender = locale('info.title'),
subject = locale('info.subject'),
message = locale('info.message'),
button = {}
})
else
exports.qbx_core:Notify(Lang:t('info.message'), 'success')
exports.qbx_core:Notify(locale('info.message'), 'success')
end
end
else
Expand Down
10 changes: 5 additions & 5 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ version '1.0.0'

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

client_script 'client/main.lua'
Expand All @@ -21,8 +18,11 @@ server_scripts {

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

lua54 'yes'
use_experimental_fxv2_oal 'yes'
use_experimental_fxv2_oal 'yes'

ox_lib 'locale'
29 changes: 29 additions & 0 deletions locales/cs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"error": {
"negative": "Zkoušíte prodat záporné množství?",
"no_melt": "Nedal jste mi nic k rozpuštění...",
"no_items": "Nedostatek položek"
},
"success": {
"sold": "Prodali jste %s x %s za $%s",
"items_received": "Obdrželi jste %s x %s"
},
"info": {
"title": "Zastavárna",
"subject": "Rozpouštění položek",
"message": "Dokončili jsme rozpuštění vašich položek. Můžete si je přijít kdykoliv vyzvednout.",
"open_pawn": "Otevřít zastavárnu",
"sell": "Prodat položky",
"sell_pawn": "Prodat položky zastavárně",
"melt": "Rozpustit položky",
"melt_pawn": "Otevřít místo pro rozpouštění",
"melt_pickup": "Vyzvednout rozpuštěné položky",
"pawn_closed": "Zastavárna je zavřená. Přijďte zpět mezi %s:00 dopoledne a %s:00 odpoledne",
"sell_items": "Prodejní cena $%s",
"back": "⬅ Zpět",
"melt_item": "Rozpustit %s",
"max": "Maximální množství %s",
"submit": "Rozpustit",
"melt_wait": "Dejte mi %s minut a vaše věci budou rozpuštěny"
}
}
37 changes: 0 additions & 37 deletions locales/cs.lua

This file was deleted.

29 changes: 29 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"error": {
"negative": "Trying to sell a negative amount?",
"no_melt": "You didn't give me anything to melt...",
"no_items": "Not enough items"
},
"success": {
"sold": "You have sold %s x %s for $%s",
"items_received": "You received %s x %s"
},
"info": {
"title": "Pawn Shop",
"subject": "Melting Items",
"message": "We finished melting your items. You can come pick them up at any time.",
"open_pawn": "Open the Pawn Shop",
"sell": "Sell Items",
"sell_pawn": "Sell Items To The Pawn Shop",
"melt": "Melt Items",
"melt_pawn": "Open the Melting Shop",
"melt_pickup": "Pickup Melted Items",
"pawn_closed": "Pawnshop is closed. Come back between %s:00 AM - %s:00 PM",
"sell_items": "Selling Price $%s",
"back": "⬅ Go Back",
"melt_item": "Melt %s",
"max": "Max Amount %s",
"submit": "Melt",
"melt_wait": "Give me %s minutes and I'll have your stuff melted"
}
}
34 changes: 0 additions & 34 deletions locales/en.lua

This file was deleted.

29 changes: 29 additions & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"error": {
"negative": "Has intentado vender una cantidad negativa",
"no_melt": "No hay nada en la fundición...",
"no_items": "No tienes suficiente cantidad"
},
"success": {
"sold": "Has vendido %s x %s por $%s",
"items_received": "Has recibido %s x %s"
},
"info": {
"title": "Casa de Empeños",
"subject": "Artículos para fundir",
"message": "Hemos terminado de fundir sus productos. Puede venir a recogerlos cuando quiera.",
"open_pawn": "Abre la casa de empeños",
"sell": "Vender artículos",
"sell_pawn": "Vender artículos a la casa de empeños",
"melt": "Fundir productos",
"melt_pawn": "Abre la fundición",
"melt_pickup": "Recoger producto fundido",
"pawn_closed": "La casa de empeños está cerrada. Vuelve entre las %s:00 AM y las %s:00 PM",
"sell_items": "Precio de venta $%s",
"back": "⬅ Volver",
"melt_item": "Fundir %s",
"max": "Cantidad máxima %s",
"submit": "Fundir",
"melt_wait": "Dame %s minutos y fundiré tus productos"
}
}
Loading

0 comments on commit 5edbd2a

Please sign in to comment.