Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(locale): qb to ox #320

Merged
merged 4 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions client/character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,48 +80,48 @@ end

---@return string[]?
local function characterDialog()
return lib.inputDialog(Lang:t('info.character_registration_title'), {
return lib.inputDialog(locale('info.character_registration_title'), {
{
type = 'input',
required = true,
icon = 'user-pen',
label = Lang:t('info.first_name'),
label = locale('info.first_name'),
placeholder = 'Hank'
},
{
type = 'input',
required = true,
icon = 'user-pen',
label = Lang:t('info.last_name'),
label = locale('info.last_name'),
placeholder = 'Jordan'
},
{
type = 'input',
required = true,
icon = 'user-shield',
label = Lang:t('info.nationality'),
label = locale('info.nationality'),
placeholder = 'Duck'
},
{
type = 'select',
required = true,
icon = 'circle-user',
label = Lang:t('info.gender'),
placeholder = Lang:t('info.select_gender'),
label = locale('info.gender'),
placeholder = locale('info.select_gender'),
options = {
{
value = Lang:t('info.char_male')
value = locale('info.char_male')
},
{
value = Lang:t('info.char_female')
value = locale('info.char_female')
}
}
},
{
type = 'date',
required = true,
icon = 'calendar-days',
label = Lang:t('info.birth_date'),
label = locale('info.birth_date'),
format = 'YYYY-MM-DD',
returnString = true,
min = '1900-01-01', -- Has to be in the same in the same format as the format argument
Expand Down Expand Up @@ -223,7 +223,7 @@ local function createCharacter(cid)

for input = 1, 3 do -- Run through first 3 inputs, aka first name, last name and nationality
if not checkStrings(dialog, input) then
Notify(Lang:t('error.no_match_character_registration'), 'error', 10000)
Notify(locale('error.no_match_character_registration'), 'error', 10000)
goto noMatch
break
end
Expand All @@ -234,7 +234,7 @@ local function createCharacter(cid)
firstname = capString(dialog[1]),
lastname = capString(dialog[2]),
nationality = capString(dialog[3]),
gender = dialog[4] == Lang:t('info.char_male') and 0 or 1,
gender = dialog[4] == locale('info.char_male') and 0 or 1,
birthdate = dialog[5],
cid = cid
})
Expand Down Expand Up @@ -280,10 +280,10 @@ local function chooseCharacter()
local character = characters[i]
local name = character and character.charinfo.firstname .. ' ' .. character.charinfo.lastname
options[i] = {
title = character and string.format('%s %s - %s', character.charinfo.firstname, character.charinfo.lastname, character.citizenid) or Lang:t('info.multichar_new_character', { number = i }),
title = character and string.format('%s %s - %s', character.charinfo.firstname, character.charinfo.lastname, character.citizenid) or locale('info.multichar_new_character', i),
metadata = character and {
Name = name,
Gender = character.charinfo.gender == 0 and Lang:t('info.char_male') or Lang:t('info.char_female'),
Gender = character.charinfo.gender == 0 and locale('info.char_male') or locale('info.char_female'),
Birthdate = character.charinfo.birthdate,
Nationality = character.charinfo.nationality,
['Account Number'] = character.charinfo.account,
Expand Down Expand Up @@ -317,16 +317,16 @@ local function chooseCharacter()
menu = 'qbx_core_multichar_characters',
options = {
{
title = Lang:t('info.play'),
description = Lang:t('info.play_description', { playerName = name }),
title = locale('info.play'),
description = locale('info.play_description', name),
icon = 'play',
onSelect = function()
DoScreenFadeOut(10)
lib.callback.await('qbx_core:server:loadCharacter', false, character.citizenid)
if GetResourceState('qbx_apartments'):find('start') then
TriggerEvent('apartments:client:setupSpawnUI', { citizenid = character.citizenid })
TriggerEvent('apartments:client:setupSpawnUI', character.citizenid)
elseif GetResourceState('qbx_spawn'):find('start') then
TriggerEvent('qb-spawn:client:setupSpawns', { citizenid = character.citizenid })
TriggerEvent('qb-spawn:client:setupSpawns', character.citizenid)
TriggerEvent('qb-spawn:client:openUI', true)
else
spawnLastLocation()
Expand All @@ -335,13 +335,13 @@ local function chooseCharacter()
end
},
config.characters.enableDeleteButton and {
title = Lang:t('info.delete_character'),
description = Lang:t('info.delete_character_description', { playerName = name }),
title = locale('info.delete_character'),
description = locale('info.delete_character_description', name),
icon = 'trash',
onSelect = function()
local alert = lib.alertDialog({
header = Lang:t('info.delete_character'),
content = Lang:t('info.confirm_delete'),
header = locale('info.delete_character'),
content = locale('info.confirm_delete'),
centered = true,
cancel = true
})
Expand All @@ -361,7 +361,7 @@ local function chooseCharacter()

lib.registerContext({
id = 'qbx_core_multichar_characters',
title = Lang:t('info.multichar_title'),
title = locale('info.multichar_title'),
canClose = false,
options = options
})
Expand Down
6 changes: 3 additions & 3 deletions client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end)
RegisterNetEvent('QBCore:Command:GoToMarker', function()
local blipMarker <const> = GetFirstBlipInfoId(8)
if not DoesBlipExist(blipMarker) then
Notify(Lang:t("error.no_waypoint"), 'error')
Notify(locale("error.no_waypoint"), 'error')
return 'marker'
end

Expand Down Expand Up @@ -120,12 +120,12 @@ RegisterNetEvent('QBCore:Command:GoToMarker', function()
-- If we can't find the coords, set the coords to the old ones.
-- We don't unpack them before since they aren't in a loop and only called once.
SetPedCoordsKeepVehicle(ped, oldCoords.x, oldCoords.y, oldCoords.z - 1.0)
Notify(Lang:t("error.tp_error"), 'error')
Notify(locale("error.tp_error"), 'error')
end

-- If Z coord was found, set coords in found coords.
SetPedCoordsKeepVehicle(ped, x, y, groundZ)
Notify(Lang:t("success.teleported_waypoint"), 'success')
Notify(locale("success.teleported_waypoint"), 'success')
end)

-- Vehicle Commands
Expand Down
2 changes: 2 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ QBX.PlayerData = {}
QBX.Shared = require 'shared.main'
QBX.IsLoggedIn = false

lib.locale()

---@return table<string, Job>
function GetJobs()
return QBX.Shared.Jobs
Expand Down
5 changes: 2 additions & 3 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ shared_scripts {
'@ox_lib/init.lua',
'modules/utils.lua',
'shared/locale.lua',
'locale/en.lua',
'locale/*.lua',
}

client_scripts {
Expand Down Expand Up @@ -52,7 +50,8 @@ files {
'bridge/qb/shared/main.lua',
'bridge/qb/shared/export-function.lua',
'config/client.lua',
'config/shared.lua'
'config/shared.lua',
'locales/*.json'
}

dependencies {
Expand Down
26 changes: 26 additions & 0 deletions locale/ar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"error": {
"not_online": "اللاعب غير متصل",
"wrong_format": "التنسيق غير صحيح",
"missing_args": "(x, y, z) لم يتم ادخل جميع المعلومات",
"missing_args2": "يجب ملأ جميع الحقول اللازمة",
"no_access": "لا يمكن الوصول إلى هذا الأمر",
"company_too_poor": "مسؤول الوظيفة لا يمكلك مال كاف-ي",
"item_not_exist": "عنصر غير موجود",
"too_heavy": "لا يوجد مساحة في جقيبتك",
"duplicate_license": "وجدنا ترخيص روكستار مكرر او موجود مسبقا",
"no_valid_license": "ترخيص روكستار غير صحيح",
"not_whitelisted": "عضويتك غير مفعلة في هذا السيرفر"
},
"success": {},
"info": {
"received_paycheck": "$%s لقد استملت راتبك الشهري",
"job_info": "%s | %s | %s",
"gang_info": "%s | %s",
"on_duty": "انت الان في الخدمة",
"off_duty": "انت الان خارج الخدمة",
"checking_ban": "نحن نتحقق اذا كنت محجوب من السيرفر. %s مرحبا",
"join_server": "%s قي %s مرحبا",
"checking_whitelisted": "نتحقق ما اذا كان مسموح لك بالدخول %s مرحبا "
}
}
34 changes: 0 additions & 34 deletions locale/ar.lua

This file was deleted.

120 changes: 120 additions & 0 deletions locale/bg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"error": {
"not_online": "Играчът не е онлайн",
"wrong_format": "Некоректен формат",
"missing_args": "Не всички аргументи са въведени (x, y, z)",
"missing_args2": "Всички аргументи трябва да бъдат попълнени!",
"no_access": "Нямате достъп до тази команда",
"company_too_poor": "Твоят работодател е фалирал",
"item_not_exist": "Артикулът не съществува",
"too_heavy": "Ивентарът е препълнен",
"location_not_exist": "Локацията не съществува",
"duplicate_license": "Намерен е дубликат на Rockstar лиценза",
"no_valid_license": "Не е намерен валиден Rockstar лиценз",
"not_whitelisted": "Вие не сте включени в белия списък за този сървър",
"server_already_open": "Сървърът вече е отворен",
"server_already_closed": "Сървърът вече е затворен",
"no_permission": "Нямате разрешения за това ..",
"no_waypoint": "Няма зададена точка.",
"tp_error": "Грешка при телепортиране.",
"connecting_database_timeout": "Свързването с базата данни изтече. (SQL сървърът работи ли?)"
},
"success": {
"server_opened": "Сървърът е отворен",
"server_closed": "Сървърът е затворен",
"teleported_waypoint": "Телепортиран до точка."
},
"info": {
"received_paycheck": "Получихте заплатата си от $%s",
"job_info": "Работа: %s | Ранг: %s | Дежурство: %s",
"gang_info": "Банда: %s | Ранг: %s",
"on_duty": "Вече сте на дежурство!",
"off_duty": "Вече не сте на дежурство!",
"checking_ban": "Здравей %s. Проверяваме дали сте баннат.",
"join_server": "Добре дошъл %s в {Име на сървъра}.",
"checking_whitelisted": "Здравей %s. Проверяваме вашето разрешение.",
"exploit_banned": "Бяхте баннат за измама. Проверете нашия Discord за повече информация: %s",
"exploit_dropped": "Бяхте изхвърлен за използване на експлоит"
},
"command": {
"tp": {
"help": "ТП към Играч или Координати (Само за админи)",
"params": {
"x": { "name": "id/x", "help": "ID на играча или X позиция" },
"y": { "name": "y", "help": "Y позиция" },
"z": { "name": "z", "help": "Z позиция" }
}
},
"tpm": { "help": "ТП до Маркер (Само за админи)" },
"togglepvp": { "help": "Превключване на PVP на сървъра (Само за админи)" },
"addpermission": {
"help": "Дайте на играч разрешения (Само за Бог)",
"params": {
"id": { "name": "id", "help": "ID на играча" },
"permission": { "name": "permission", "help": "Ниво на разрешение" }
}
},
"removepermission": {
"help": "Премахнете разрешенията на играча (Само за Бог)",
"params": {
"id": { "name": "id", "help": "ID на играча" },
"permission": { "name": "permission", "help": "Ниво на разрешение" }
}
},
"openserver": { "help": "Отворете сървъра за всички (Само за админи)" },
"closeserver": {
"help": "Затворете сървъра за хора без разрешения (Само за админи)",
"params": {
"reason": { "name": "reason", "help": "Причина за затваряне (по избор)" }
}
},
"car": {
"help": "Изваждане на превозно средство от джоба (Само за админи)",
"params": {
"model": { "name": "model", "help": "Модел на превозното средство" }
}
},
"dv": { "help": "Прибиране на превозно средство в джоба (Само за админи)" },
"givemoney": {
"help": "Дайте на играч пари (Само за админи)",
"params": {
"id": { "name": "id", "help": "ID на играча" },
"moneytype": { "name": "moneytype", "help": "Тип пари (cash, bank, crypto)" },
"amount": { "name": "amount", "help": "Сума пари" }
}
},
"setmoney": {
"help": "Задайте сумата на парите на играча (Само за админи)",
"params": {
"id": { "name": "id", "help": "ID на играча" },
"moneytype": { "name": "moneytype", "help": "Тип пари (cash, bank, crypto)" },
"amount": { "name": "amount", "help": "Сума пари" }
}
},
"job": { "help": "Проверка на работата ви" },
"setjob": {
"help": "Задайте работата на играча (Само за админи)",
"params": {
"id": { "name": "id", "help": "ID на играча" },
"job": { "name": "job", "help": "Име на работата" },
"grade": { "name": "grade", "help": "Ранг на работата" }
}
},
"gang": { "help": "Проверете вашата банда" },
"setgang": {
"help": "Задайте бандата на играча (Само за админи)",
"params": {
"id": { "name": "id", "help": "ID на играча" },
"gang": { "name": "gang", "help": "Име на бандата" },
"grade": { "name": "grade", "help": "Ранг на бандата" }
}
},
"ooc": { "help": "OOC чат съобщение" },
"me": {
"help": "Показване на локално съобщение",
"params": {
"message": { "name": "message", "help": "Съобщение за изпращане" }
}
}
}
}
Loading
Loading