From d95ac08d0ab0361a5bb072e039dce84996b15506 Mon Sep 17 00:00:00 2001 From: nearbyplayer Date: Tue, 15 Aug 2017 14:59:46 -0400 Subject: [PATCH] Multi-language support Updated readme with proper clone link, and moved it to the front directory. --- esx_weashops/LICENSE.txt => LICENSE.txt | 0 esx_weashops/README.md => README.md | 2 +- esx_weashops/__resource.lua => __resource.lua | 6 ++++++ {esx_weashops/client => client}/main.lua | 8 ++++---- esx_weashops/config.lua => config.lua | 1 + esx_weashops/esx_weashops.sql => esx_weashops.sql | 0 locales/en.lua | 10 ++++++++++ locales/fr.lua | 10 ++++++++++ {esx_weashops/server => server}/main.lua | 10 +++++----- 9 files changed, 37 insertions(+), 10 deletions(-) rename esx_weashops/LICENSE.txt => LICENSE.txt (100%) rename esx_weashops/README.md => README.md (74%) rename esx_weashops/__resource.lua => __resource.lua (55%) rename {esx_weashops/client => client}/main.lua (94%) rename esx_weashops/config.lua => config.lua (95%) rename esx_weashops/esx_weashops.sql => esx_weashops.sql (100%) create mode 100644 locales/en.lua create mode 100644 locales/fr.lua rename {esx_weashops/server => server}/main.lua (76%) diff --git a/esx_weashops/LICENSE.txt b/LICENSE.txt similarity index 100% rename from esx_weashops/LICENSE.txt rename to LICENSE.txt diff --git a/esx_weashops/README.md b/README.md similarity index 74% rename from esx_weashops/README.md rename to README.md index cecf165..284f1eb 100644 --- a/esx_weashops/README.md +++ b/README.md @@ -6,7 +6,7 @@ FXServer ESX Weapon Shops 1) CD in your resources/[esx] folder 2) Clone the repository ``` - +git clone https://github.com/FXServer-ESX/fxserver-esx_weashops.git esx_weashops ``` 3) Import esx_weashops.sql in your database 4) Add this in your server.cfg : diff --git a/esx_weashops/__resource.lua b/__resource.lua similarity index 55% rename from esx_weashops/__resource.lua rename to __resource.lua index 47caca5..34c968b 100644 --- a/esx_weashops/__resource.lua +++ b/__resource.lua @@ -1,11 +1,17 @@ description 'ESX Mecano 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', '@mysql-async/lib/MySQL.lua', 'config.lua', 'server/main.lua' diff --git a/esx_weashops/client/main.lua b/client/main.lua similarity index 94% rename from esx_weashops/client/main.lua rename to client/main.lua index fc3ac61..e07aca9 100644 --- a/esx_weashops/client/main.lua +++ b/client/main.lua @@ -45,7 +45,7 @@ function OpenShopMenu(zone) ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'shop', { - title = 'Magasin', + title = _U('shop'), elements = elements }, function(data, menu) @@ -56,7 +56,7 @@ function OpenShopMenu(zone) menu.close() CurrentAction = 'shop_menu' - CurrentActionMsg = 'Appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.' + CurrentActionMsg = _U('shop_menu') CurrentActionData = {zone = zone} end ) @@ -65,7 +65,7 @@ end AddEventHandler('esx_weashop:hasEnteredMarker', function(zone) CurrentAction = 'shop_menu' - CurrentActionMsg = 'Appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.' + CurrentActionMsg = _U('shop_menu') CurrentActionData = {zone = zone} end) @@ -89,7 +89,7 @@ Citizen.CreateThread(function() SetBlipColour (blip, 2) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") - AddTextComponentString("GunShop") + AddTextComponentString(_U('map_blip')) EndTextCommandSetBlipName(blip) end end diff --git a/esx_weashops/config.lua b/config.lua similarity index 95% rename from esx_weashops/config.lua rename to config.lua index 5006a70..e4e843f 100644 --- a/esx_weashops/config.lua +++ b/config.lua @@ -4,6 +4,7 @@ Config.DrawDistance = 100 Config.Size = {x = 1.5, y = 1.5, z = 1.5} Config.Color = {r = 0, g = 128, b = 255} Config.Type = 1 +Config.Locale = 'en' Config.Zones = { diff --git a/esx_weashops/esx_weashops.sql b/esx_weashops.sql similarity index 100% rename from esx_weashops/esx_weashops.sql rename to esx_weashops.sql diff --git a/locales/en.lua b/locales/en.lua new file mode 100644 index 0000000..a833c4c --- /dev/null +++ b/locales/en.lua @@ -0,0 +1,10 @@ +Locales ['en'] = { + + ['buy'] = 'you bought', + ['not_enough_black'] = 'you do not have enough dirty money', + ['not_enough'] = 'you do not have enough money', + ['shop'] = 'shop', + ['shop_menu'] = 'Press ~INPUT_CONTENT~ to access the shop.', + ['map_blip'] = 'gun shop', + +} \ No newline at end of file diff --git a/locales/fr.lua b/locales/fr.lua new file mode 100644 index 0000000..1b3b5ca --- /dev/null +++ b/locales/fr.lua @@ -0,0 +1,10 @@ +Locales ['fr'] = { + + ['buy'] = 'vous avez acheté ~b~1x ', + ['not_enough_black'] = 'Vous n\'avez ~r~pas assez~s~ d\'argent sale', + ['not_enough'] = 'vous n\'avez ~r~pas assez~s~ d\'argent', + ['shop'] = 'magasin', + ['shop_menu'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.', + ['map_blip'] = 'armurerie', + +} \ No newline at end of file diff --git a/esx_weashops/server/main.lua b/server/main.lua similarity index 76% rename from esx_weashops/server/main.lua rename to server/main.lua index ae222d5..56b8149 100644 --- a/esx_weashops/server/main.lua +++ b/server/main.lua @@ -50,7 +50,7 @@ ESX.RegisterServerCallback('esx_weashop:requestDBItems', function(source, cb) end) RegisterServerEvent('esx_weashop:buyItem') -AddEventHandler('esx_weashop:buyItem', function(itemName, price,zone) +AddEventHandler('esx_weashop:buyItem', function(itemName, price, zone) local _source = source local xPlayer = ESX.GetPlayerFromId(source) @@ -61,10 +61,10 @@ AddEventHandler('esx_weashop:buyItem', function(itemName, price,zone) xPlayer.removeAccountMoney('black_money', price) xPlayer.addWeapon(itemName, 42) - TriggerClientEvent('esx:showNotification', _source, 'Vous avez acheté ~b~1x ' .. ItemsLabels[itemName]) + TriggerClientEvent('esx:showNotification', _source, _U('buy') .. ItemsLabels[itemName]) else - TriggerClientEvent('esx:showNotification', _source, 'Vous n\'avez ~r~pas assez~s~ d\'argent sale') + TriggerClientEvent('esx:showNotification', _source, _U('not_enough_black')) end else if xPlayer.get('money') >= price then @@ -72,10 +72,10 @@ AddEventHandler('esx_weashop:buyItem', function(itemName, price,zone) xPlayer.removeMoney(price) xPlayer.addWeapon(itemName, 42) - TriggerClientEvent('esx:showNotification', _source, 'Vous avez acheté ~b~1x ' .. ItemsLabels[itemName]) + TriggerClientEvent('esx:showNotification', _source, _U('buy') .. ItemsLabels[itemName]) else - TriggerClientEvent('esx:showNotification', _source, 'Vous n\'avez ~r~pas assez~s~ d\'argent.') + TriggerClientEvent('esx:showNotification', _source, _U('not_enough')) end end