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

Add intenationalization to Frontend #117

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
38 changes: 23 additions & 15 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ local function sendUIUpdateMessage(data)
})
end

local function sendUILang()
SendNUIMessage({
action = 'setLang',
lang = GetConvar('qb_locale', 'en')
})
end

local function HandleSetupResource()
QBCore.Functions.TriggerCallback('hud:server:getRank', function(isAdminOrGreater)
if isAdminOrGreater then
Expand All @@ -126,6 +133,7 @@ local function HandleSetupResource()
sendUIUpdateMessage(UIConfig)
end
end
sendUILang()
end

RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function()
Expand Down Expand Up @@ -254,7 +262,7 @@ RegisterNUICallback('openMenuSounds', function(data, cb)
Menu.isOpenMenuSoundsChecked = true
else
Menu.isOpenMenuSoundsChecked = false
end
end
TriggerEvent("hud:client:playHudChecklistSound")
end)

Expand Down Expand Up @@ -867,15 +875,15 @@ end

CreateThread(function()
local wasInVehicle = false
while true do
while true do
if LocalPlayer.state.isLoggedIn then
Wait(500)

local show = true
local player = PlayerPedId()
local playerId = PlayerId()
local weapon = GetSelectedPedWeapon(player)

-- Player hud
if not IsWhitelistedWeaponArmed(weapon) then
-- weapon ~= 0 fixes unarmed on Offroad vehicle Blzer Aqua showing armed bug
Expand All @@ -893,13 +901,13 @@ CreateThread(function()
if not IsEntityInWater(player) then
oxygen = 100 - GetPlayerSprintStaminaRemaining(playerId)
end

-- Oxygen
if IsEntityInWater(player) then
oxygen = GetPlayerUnderwaterTimeRemaining(playerId) * 10
end

-- Voice setup
-- Voice setup
local talking = NetworkIsPlayerTalking(playerId)
local voice = 0
if LocalPlayer.state['proximity'] then
Expand Down Expand Up @@ -957,7 +965,7 @@ CreateThread(function()
end

wasInVehicle = true

updatePlayerHud({
show,
GetEntityHealth(player) - 100,
Expand Down Expand Up @@ -1304,19 +1312,19 @@ CreateThread(function()
else
heading = tostring(round(360.0 - GetEntityHeading(player)))
end
if heading == '360' then
heading = '0'

if heading == '360' then
heading = '0'
end

local playerInVehcile = IsPedInAnyVehicle(player)

if heading ~= lastHeading or lastInVehicle ~= playerInVehcile then
if playerInVehcile then
local crossroads = getCrossroads(player)
SendNUIMessage ({
action = 'update',
value = heading
SendNUIMessage ({
action = 'update',
value = heading
})
updateBaseplateHud({
show,
Expand All @@ -1330,9 +1338,9 @@ CreateThread(function()
lastInVehicle = true
else
if not Menu.isOutCompassChecked then
SendNUIMessage ({
action = 'update',
value = heading
SendNUIMessage ({
action = 'update',
value = heading
})
SendNUIMessage ({
action = 'baseplate',
Expand Down
95 changes: 95 additions & 0 deletions html/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"hudSettings": "HUD Settings",
"statusIcons": "Status Icons",
"resetHud": "Reset HUD",
"resetSettings": "Reset Settings",
"resettingHud": "Resetting Hud...",
"resetHudDescription": "If your hud is acting up, give it a good ol' reset! Or you can do /resethud",
"resetSettingsDescriptionLine1": "If you want to reset your settings back to default; click this shiny button!",
"resetSettingsDescriptionLine2": "(you will have to relog for your menu to reset changes successfully)",
"optionsMenu": "Options",
"minimapVehicleCheckBoxPrimary": "Show Minimap Only in Vehicle",
"minimapVehicleCheckBoxSecondary": "Disabling this will always keep your minimap on your screen",
"compassVehicleCheckBoxPrimary": "Show Compass Only in Vehicle",
"compassVehicleCheckBoxSecondary": "Disabling this will always keep your compass on your screen",
"compassFollowCheckBoxPrimary": "Show Compass Follow Cam",
"compassFollowCheckBoxSecondary": "Disabling this will make it so you can no longer use your mouse to rotate the compass around",
"notificationsMenu": "Notifications",
"menuSoundEffectsEnabled": "Menu Sound Effect Enabled",
"resetSoundEffectsEnabled": "Reset Hud Sound Effects Enabled",
"guiSoundEffectsEnabled": "GUI Sound Effects Enabled",
"mapNotificationsEnabled": "Map Notifications Enabled",
"lowFuelNotificationsEnabled": "Low Fuel Alert Enabled",
"cinematicModeNotificationEnabled": "Cinematic Mode Notifications",
"statusMenu": "Status",
"showHealthAlways": "Show Health Always",
"showArmorAlways": "Show Armor Always",
"showHungerAlways": "Show Hunger Always",
"showThirstAlways": "Show Thirst Always",
"showStressAlways": "Show Stress Always",
"showOxygenAlways": "Show Oxygen Always",
"vehicleMenu": "Vehicle",
"minimapTypeCircle": "Minimap Circle",
"minimapTypeSquare": "Minimap Square",
"minimapTypeDescription": "Whether it's square or circle you desire, you have the ability to choose!",
"minimapEnabled": "Minimap Enabled",
"minimapBordersEnabled": "Minimap Borders Enabled",
"showEngineAlways": "Show Engine Always",
"showNitroAlways": "Show Nitro Always",
"compassMenu": "Compass",
"compassEnabled": "Compass Enabled",
"compassEnabledDescription": "Disabling this will make it so you can't see the compass navigation",
"showStreetNamesEnabled": "Show Street Names Enabled",
"showStreetNamesDescription": "Disabling this will make it so you can't see the street names / locations",
"showCompassPointerEnabled": "Show Compass Pointer Enabled",
"showCompassPointerDescription": "Disabling this will make it so you can't see your pointer index to pinpoint your exact cardinal directions",
"cinematicMenu": "Cinematic Mode",
"showCinematicBarsEnabled": "Show Cinematic Bars Enabled",
"statusIconsSettings": "Status Icons Settings",
"designMode": "Design Mode",
"resetStatusIconSettings": "Reset Status Icon Settings",
"saveChangesToServer": "Save Changes To Server",
"globalStatusIconsSettings": "Global Status Icons Settings",
"iconShape": "Icon Shape",
"globalSizeAndPositionSection": "Global Size & Position Section",
"widthSize": "Width Size",
"heightSize": "Height Size",
"ringSize": "Ring Size",
"showProgressOutline": "Show Progress Outline",
"xAxisPosition": "X-Axis Position",
"yAxisPosition": "Y-Axis Position",
"rotation": "Rotation",
"iconXAxisPosition": "Icon X-Axis Position",
"iconYAxisPosition": "Icon Y-Axis Position",
"iconSize": "Icon Size",
"xAxisCurve": "X-Axis Curve",
"yAxisCurve": "Y-Axis Curve",
"globalColorSection": "Global Color Section",
"progressColor": "Progress Color",
"progressContrast": "Progress Contrast",
"progressShadow": "Progress Shadow",
"iconColor": "Icon Color",
"iconContrast": "Icon Contrast",
"iconShadow": "Icon Shadow",
"outlineColor": "Outline Color",
"outlineContrast": "Outline Contrast",
"outlineShadow": "Outline Shadow",
"innerColor": "Inner Color",
"singleStatusIconSettings": "Single Status Icon Settings",
"iconStatusToEdit": "Icon Status To Edit",
"singleIconSizeAndPositionSection": "Single Icon Size & Position Section",
"singleIconColorSection": "Single Icon Color Section",
"globalStatusIconLayoutSettings": "Global Status Icon Layout Settings",
"iconLayout": "Icon Layout",
"iconState": "Icon State",
"betweenIconSpacing": "Between Icon Spacing",
"yAxisSpacing": "Y-Axis Spacing",
"xAxisSpacing": "X-Axis Spacing",
"utilityFunctions": "Utility Functions",
"copyProgressColorsToIconsColors": "Copy Progress Colors To Icon Colors",
"customizationProfiles": "Customization Profiles",
"addNewProfile": "Add New Profile",
"saveHudToProfile": "Save HUD To Profile",
"applyProfileToHud": "Apply Profile To HUD",
"deleteProfile": "Delete Profile"
}
300 changes: 148 additions & 152 deletions html/index.js

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions html/pt-br.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"hudSettings": "Configurações do HUD",
"statusIcons": "Ícones de Status",
"resetHud": "Resetar HUD",
"resetSettings": "Resetar Configurações",
"resettingHud": "Resetando Hud...",
"resetHudDescription": "Se seu HUD está com problemas, dê um velho reset! Ou pode usar o comando: /resethud",
"resetSettingsDescriptionLine1": "Se você quiser resetar suas confgurações para o padrão; clique neste botão luminoso!",
"resetSettingsDescriptionLine2": "(você terá que relogar para o menu resetar as configurações corretamente)",
"optionsMenu": "Opções",
"minimapVehicleCheckBoxPrimary": "Mostrar Minimapa Somente em Veículo",
"minimapVehicleCheckBoxSecondary": "Desativar isso vai deixar o minimapa na tela o tempo todo",
"compassVehicleCheckBoxPrimary": "Mostrar Bússola Somente em Veículo",
"compassVehicleCheckBoxSecondary": "Desativar isso vai deicar a bússola na tela o tempo todo",
"compassFollowCheckBoxPrimary": "Girar Bússola com a Câmera",
"compassFollowCheckBoxSecondary": "Desativar isso fará com que não seja mais possível rotacionar a bússola usando o mouse",
"notificationsMenu": "Notificações",
"menuSoundEffectsEnabled": "Ativar Efeitos sonoros do Menu",
"resetSoundEffectsEnabled": "Resetar Efeitos sonoros do HUD",
"guiSoundEffectsEnabled": "Ativar Efeitos sonoros da interface",
"mapNotificationsEnabled": "Ativar Notificações do Mapa",
"lowFuelNotificationsEnabled": "Ativar Aviso de Combustível Baixo",
"cinematicModeNotificationEnabled": "Notificações do Modo Cinematográfico",
"statusMenu": "Status",
"showHealthAlways": "Exibir Saúde Sempre",
"showArmorAlways": "Exibir Armadura Sempre",
"showHungerAlways": "Exibir Fome Sempre",
"showThirstAlways": "Exibir Sede Sempre",
"showStressAlways": "Exibir Estresse Sempre",
"showOxygenAlways": "Exibir Oxigênio Sempre",
"vehicleMenu": "Veículo",
"minimapTypeCircle": "Minimapa Circular",
"minimapTypeSquare": "Minimapa Quadrado",
"minimapTypeDescription": "Se é quadrado ou redondo que você deseja, você tem a opção de escolha!",
"minimapEnabled": "Ativar Minimapa",
"minimapBordersEnabled": "Ativar Bordas do Minimapa",
"showEngineAlways": "Exibir Motor Semrpe",
"showNitroAlways": "Exibir Nitro Semrpe",
"compassMenu": "Bússola",
"compassEnabled": "Ativar Bússola",
"compassEnabledDescription": "Desativar isso fará com que você não veja a navegação por bússola",
"showStreetNamesEnabled": "Ativar Nomes de Ruas",
"showStreetNamesDescription": "Desativar isso fará com que você não veja os nomes das ruas / locais",
"showCompassPointerEnabled": "Ativar Ponteiro da Bússola",
"showCompassPointerDescription": "Desativar isso fará com que você não veja o ponteiro da bússola para saber com exatidão sua direção",
"cinematicMenu": "Modo Cinematográfico",
"showCinematicBarsEnabled": "Exibir Barras do Modo Cinematográfico",
"statusIconsSettings": "Configurações dos Ícones de Status",
"designMode": "Modo de Design",
"resetStatusIconSettings": "Resetar Configurações de Ícones de Status",
"saveChangesToServer": "Salvar Configurações do Servidor",
"globalStatusIconsSettings": "Configurações Globais de Ícones de Status",
"iconShape": "Forma do Ícone",
"globalSizeAndPositionSection": "Seção de Tamanho e Posição Global",
"widthSize": "Largura",
"heightSize": "Altura",
"ringSize": "Tamanho do Anel",
"showProgressOutline": "Mostrar Borda Exterior de Progresso",
"xAxisPosition": "Posição Eixo X",
"yAxisPosition": "Posição Eixo Y",
"rotation": "Rotação",
"iconXAxisPosition": "Posição Eixo X Ícone",
"iconYAxisPosition": "Posição Eixo Y Ícone",
"iconSize": "Tamanho do Ícone",
"xAxisCurve": "Curva do Eixo X",
"yAxisCurve": "Curva do Eixo Y",
"globalColorSection": "Seção de Cores Globais",
"progressColor": "Cor do Progresso",
"progressContrast": "Contraste do Progresso",
"progressShadow": "Sombra do Progresso",
"iconColor": "Cor do Ícone",
"iconContrast": "Contraste do Ícone",
"iconShadow": "Sombra do Ícone",
"outlineColor": "Cor da Borda Exterior",
"outlineContrast": "Contraste da Borda Exterior",
"outlineShadow": "Sombre da Borda Exterior",
"innerColor": "Cor Interna",
"singleStatusIconSettings": "Configurações Unitárias do Ícone de Status",
"iconStatusToEdit": "Ícone de Status Para Editar",
"singleIconSizeAndPositionSection": "Seção Unitária de Tamanho e Posicionamento",
"singleIconColorSection": "Seção Unitária de Cor do Ícone",
"globalStatusIconLayoutSettings": "Configurações Globais de Leiaute de Ícones de Status",
"iconLayout": "Leiaute dos Ícones",
"iconState": "Estado do Ícone",
"betweenIconSpacing": "Espaçamento entre Ícones",
"yAxisSpacing": "Espaçamento do Eixo Y",
"xAxisSpacing": "Espaçamento do Eixo X",
"utilityFunctions": "Funções Utilitárias",
"copyProgressColorsToIconsColors": "Copiar Cores de Progress Para Cores dos Ícones",
"customizationProfiles": "Perfis Customizados",
"addNewProfile": "Novo Perfil",
"saveHudToProfile": "Salvar HUD no Perfil",
"applyProfileToHud": "Aplicar Perfil para HUD",
"deleteProfile": "Apagar Perfil"
}
2 changes: 1 addition & 1 deletion html/vendor.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions svelte-source/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"typescript": "^4.6.2",
"vite": "^2.8.6",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-static-copy": "^1.0.2",
"vite-plugin-windicss": "^1.8.3",
"windicss": "^3.5.1"
},
Expand Down
5 changes: 3 additions & 2 deletions svelte-source/src/components/menu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { draggable } from '@neodrag/svelte';
import { faSliders, faCircleNotch } from '@fortawesome/free-solid-svg-icons'
import Fa from 'svelte-fa'
import { i18n } from '../utils/i18n';

import MenuStore from '../stores/menuStore';

Expand All @@ -13,8 +14,8 @@
const screenHeight: number = screen.height;

let tabArray: Array<{name: string, icon: any, content: any, adminOnly: boolean}> = [
{ name: "Hud Settings", icon: faSliders, content: HudPanel, adminOnly: false },
{ name: "Status Icons", icon: faCircleNotch, content: StatusIconsPanel, adminOnly: true },
{ name: $i18n.hudSettings, icon: faSliders, content: HudPanel, adminOnly: false },
{ name: $i18n.statusIcons, icon: faCircleNotch, content: StatusIconsPanel, adminOnly: true },
];
let activeTab: {name: string, icon: any, content: any} = tabArray[0];

Expand Down
11 changes: 6 additions & 5 deletions svelte-source/src/components/menu/globalLayoutPanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,32 @@
import { faTableColumns } from '@fortawesome/free-solid-svg-icons';
import { iconLayouts } from '../../types/types';
import LayoutStore from '../../stores/layoutStore';
import { i18n } from '../../utils/i18n';

export let group: string = "";
</script>


<Panel name={'Global Status Icon Layout Settings'} icon={faTableColumns} color={"white"} bind:group>
<Panel name={$i18n.globalStatusIconLayoutSettings} icon={faTableColumns} color={"white"} bind:group>
<div class="text-sm flex flex-col text-[#e8e8e8]">
<div class="flex justify-center mb-4">
<div class="w-55">
<p class="text-lg text-center mb-2">Icon Layout</p>
<p class="text-lg text-center mb-2">{$i18n.iconLayout}</p>
<Select valuesArray={iconLayouts} value={$LayoutStore.layout} handleSelectFunction={LayoutStore.updateLayout}/>
</div>
</div>

<div class="mx-4 grid grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-6 items-end mb-8">
<div>
<p class="text-base text-center mb-2">Between Icon Spacing</p>
<p class="text-base text-center mb-2">{$i18n.betweenIconSpacing}</p>
<NumberInput min={-100} max={200} bind:value={$LayoutStore.iconBetweenSpacing}/>
</div>
<div>
<p class="text-base text-center mb-2">Y-Axis Spacing</p>
<p class="text-base text-center mb-2">{$i18n.yAxisSpacing}</p>
<NumberInput min={-100} max={500} bind:value={$LayoutStore.yAxisSpacing}/>
</div>
<div>
<p class="text-base text-center mb-2">X-Axis Spacing</p>
<p class="text-base text-center mb-2">{$i18n.xAxisSpacing}</p>
<NumberInput min={-100} max={500} bind:value={$LayoutStore.xAxisSpacing}/>
</div>
</div>
Expand Down
Loading