Added Locale
This commit is contained in:
1 parent
1630a76701
commit
6db88bee29
8 files changed
+58
-41
No files matched your search
@@ -112,9 +112,14 @@ RegisterNUICallback('get_config', function(data, cb)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('nass_pedscaler:openMenu', function()
|
||||
print("Opening ped scaler menu...")
|
||||
SetNuiFocus(true, true)
|
||||
SendNUIMessage({
|
||||
action = "visible",
|
||||
data = true,
|
||||
})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('getLocale', function(data, cb)
|
||||
cb(Config.locale)
|
||||
end)
|
||||
+1
-1
@@ -15,7 +15,7 @@ Config.commands = {
|
||||
Config.permissions = {
|
||||
enabled = false,
|
||||
defaultPermissions = {
|
||||
openSelf = false,
|
||||
openSelf = true,
|
||||
openOther = false,
|
||||
resetSelf = true,
|
||||
resetOther = false,
|
||||
|
||||
+9
-2
@@ -1,6 +1,13 @@
|
||||
if Locales == nil then Locales = {} end
|
||||
|
||||
Locales["en"] = {
|
||||
["scale"] = "Scale",
|
||||
["resetscale"] = "Reset Scale",
|
||||
["height_scale"] = "Height Scale",
|
||||
["info"] = "Info",
|
||||
["info_value"] = "When entering and exiting a vehicle, the scale will be reset to 1.0.",
|
||||
["notice"] = "Notice",
|
||||
["notice_value"] = "When changing terrain you may notice sudden scale adjustments.",
|
||||
["current_scale"] = "Current Scale",
|
||||
["range"] = "Range",
|
||||
["close"] = "Close",
|
||||
["apply"] = "Apply",
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
if Locales == nil then Locales = {} end
|
||||
|
||||
Locales["es"] = {
|
||||
["height_scale"] = "Altura de la escala",
|
||||
["info"] = "Información",
|
||||
["info_value"] = "Cuando entras y sales de un vehículo, la escala se reseteará a 1.0.",
|
||||
["notice"] = "Nota",
|
||||
["notice_value"] = "Cuando cambias el terreno, puedes notar ajustes repentinos en la escala.",
|
||||
["current_scale"] = "Escala actual",
|
||||
["range"] = "Rango",
|
||||
["close"] = "Cerrar",
|
||||
["apply"] = "Aplicar",
|
||||
}
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! For license information please see app.js.LICENSE.txt */
|
||||
(()=>{"use strict";var e={522:(e,n,t)=>{t.d(n,{Z:()=>u});var r=t(81),l=t.n(r),a=t(645),o=t.n(a)()(l());o.push([e.id,"/* Reset and base styles */\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\nbody {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'SF Pro Display', system-ui, sans-serif;\n background: transparent;\n color: #ffffff;\n overflow: hidden;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n/* Animation keyframes for Tailwind conversion */\n@keyframes modalFadeIn {\n to {\n transform: translateY(-50%) scale(1);\n opacity: 1;\n }\n}",""]);const u=o},645:e=>{e.exports=function(e){var n=[];return n.toString=function(){return this.map((function(n){var t="",r=void 0!==n[5];return n[4]&&(t+="@supports (".concat(n[4],") {")),n[2]&&(t+="@media ".concat(n[2]," {")),r&&(t+="@layer".concat(n[5].length>0?" ".concat(n[5]):""," {")),t+=e(n),r&&(t+="}"),n[2]&&(t+="}"),n[4]&&(t+="}"),t})).join("")},n.i=function(e,t,r,l,a){"string"==typeof e&&(e=[[null,e,void 0]]);var o={};if(r)for(var u=0;u<this.length;u++){var i=this[u][0];null!=i&&(o[i]=!0)}for(var s=0;s<e.length;s++){var c=[].concat(e[s]);r&&o[c[0]]||(void 0!==a&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=a),t&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=t):c[2]=t),l&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=l):c[4]="".concat(l)),n.push(c))}},n}},81:e=>{e.exports=function(e){return e[1]}},448:(e,n,t)=>{var r=t(294),l=t(840);function a(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,t=1;t<arguments.length;t++)n+="&args[]="+encodeURIComponent(arguments[t]);return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,u={};function i(e,n){s(e,n),s(e+"Capture",n)}function s(e,n){for(u[e]=n,e=0;e<n.length;e++)o.add(n[e])}var c=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),f=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function h(e,n,t,r,l,a,o){this.acceptsBooleans=2===n||3===n||4===n,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=t,this.propertyName=e,this.type=n,this.sanitizeURL=a,this.removeEmptyString=o}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach((function(e){v[e]=new h(e,0,!1,e,null,!1,!1)})),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach((function(e){var n=e[0];v[n]=new h(n,1,!1,e[1],null,!1,!1)})),["contentEditable","draggable","spellCheck","value"].forEach((function(e){v[e]=new h(e,2,!1,e.toLowerCase(),null,!1,!1)})),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach((function(e){v[e]=new h(e,2,!1,e,null,!1,!1)})),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach((function(e){v[e]=new h(e,3,!1,e.toLowerCase(),null,!1,!1)})),["checked","multiple","muted","selected"].forEach((function(e){v[e]=new h(e,3,!0,e,null,!1,!1)})),["capture","download"].forEach((function(e){v[e]=new h(e,4,!1,e,null,!1,!1)})),["cols","rows","size","span"].forEach((function(e){v[e]=new h(e,6,!1,e,null,!1,!1)})),["rowSpan","start"].forEach((function(e){v[e]=new h(e,5,!1,e.toLowerCase(),null,!1,!1)}));var g=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}function b(e,n,t,r){var l=v.hasOwnProperty(n)?v[n]:null;(null!==l?0!==l.type:r||!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&(function(e,n,t,r){if(null==n||function(e,n,t,r){if(null!==t&&0===t.type)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return!r&&(null!==t?!t.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,n,t,r))return!0;if(r)return!1;if(null!==t)switch(t.type){case 3:return!n;case 4:return!1===n;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}(n,t,l,r)&&(t=null),r||null===l?function(e){return!!f.call(m,e)||!f.call(p,e)&&(d.test(e)?m[e]=!0:(p[e]=!0,!1))}(n)&&(null===t?e.removeAttribute(n):e.setAttribute(n,""+t)):l.mustUseProperty?e[l.propertyName]=null===t?3!==l.type&&"":t:(n=l.attributeName,r=l.attributeNamespace,null===t?e.removeAttribute(n):(tLine truncated
|
||||
(()=>{"use strict";var e={522:(e,n,t)=>{t.d(n,{Z:()=>u});var r=t(81),l=t.n(r),a=t(645),o=t.n(a)()(l());o.push([e.id,"/* Reset and base styles */\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\nbody {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'SF Pro Display', system-ui, sans-serif;\n background: transparent;\n color: #ffffff;\n overflow: hidden;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n/* Animation keyframes for Tailwind conversion */\n@keyframes modalFadeIn {\n to {\n transform: translateY(-50%) scale(1);\n opacity: 1;\n }\n}",""]);const u=o},645:e=>{e.exports=function(e){var n=[];return n.toString=function(){return this.map((function(n){var t="",r=void 0!==n[5];return n[4]&&(t+="@supports (".concat(n[4],") {")),n[2]&&(t+="@media ".concat(n[2]," {")),r&&(t+="@layer".concat(n[5].length>0?" ".concat(n[5]):""," {")),t+=e(n),r&&(t+="}"),n[2]&&(t+="}"),n[4]&&(t+="}"),t})).join("")},n.i=function(e,t,r,l,a){"string"==typeof e&&(e=[[null,e,void 0]]);var o={};if(r)for(var u=0;u<this.length;u++){var i=this[u][0];null!=i&&(o[i]=!0)}for(var s=0;s<e.length;s++){var c=[].concat(e[s]);r&&o[c[0]]||(void 0!==a&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=a),t&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=t):c[2]=t),l&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=l):c[4]="".concat(l)),n.push(c))}},n}},81:e=>{e.exports=function(e){return e[1]}},448:(e,n,t)=>{var r=t(294),l=t(840);function a(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,t=1;t<arguments.length;t++)n+="&args[]="+encodeURIComponent(arguments[t]);return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,u={};function i(e,n){s(e,n),s(e+"Capture",n)}function s(e,n){for(u[e]=n,e=0;e<n.length;e++)o.add(n[e])}var c=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),f=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function h(e,n,t,r,l,a,o){this.acceptsBooleans=2===n||3===n||4===n,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=t,this.propertyName=e,this.type=n,this.sanitizeURL=a,this.removeEmptyString=o}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach((function(e){v[e]=new h(e,0,!1,e,null,!1,!1)})),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach((function(e){var n=e[0];v[n]=new h(n,1,!1,e[1],null,!1,!1)})),["contentEditable","draggable","spellCheck","value"].forEach((function(e){v[e]=new h(e,2,!1,e.toLowerCase(),null,!1,!1)})),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach((function(e){v[e]=new h(e,2,!1,e,null,!1,!1)})),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach((function(e){v[e]=new h(e,3,!1,e.toLowerCase(),null,!1,!1)})),["checked","multiple","muted","selected"].forEach((function(e){v[e]=new h(e,3,!0,e,null,!1,!1)})),["capture","download"].forEach((function(e){v[e]=new h(e,4,!1,e,null,!1,!1)})),["cols","rows","size","span"].forEach((function(e){v[e]=new h(e,6,!1,e,null,!1,!1)})),["rowSpan","start"].forEach((function(e){v[e]=new h(e,5,!1,e.toLowerCase(),null,!1,!1)}));var g=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}function b(e,n,t,r){var l=v.hasOwnProperty(n)?v[n]:null;(null!==l?0!==l.type:r||!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&(function(e,n,t,r){if(null==n||function(e,n,t,r){if(null!==t&&0===t.type)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return!r&&(null!==t?!t.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,n,t,r))return!0;if(r)return!1;if(null!==t)switch(t.type){case 3:return!n;case 4:return!1===n;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}(n,t,l,r)&&(t=null),r||null===l?function(e){return!!f.call(m,e)||!f.call(p,e)&&(d.test(e)?m[e]=!0:(p[e]=!0,!1))}(n)&&(null===t?e.removeAttribute(n):e.setAttribute(n,""+t)):l.mustUseProperty?e[l.propertyName]=null===t?3!==l.type&&"":t:(n=l.attributeName,r=l.attributeNamespace,null===t?e.removeAttribute(n):(tLine truncated
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Component } from "react"
|
||||
import { Component, useState } from "react"
|
||||
import { useNui, callNui } from "./utils/FiveM"
|
||||
var locale = {}
|
||||
import '../../styles/app.css'
|
||||
import ScaleMenu from "./componenets/ScaleMenu.jsx"
|
||||
import ScaleMenu from "./components/ScaleMenu.jsx"
|
||||
|
||||
|
||||
export default class App extends Component {
|
||||
state = {
|
||||
@@ -11,7 +13,7 @@ export default class App extends Component {
|
||||
render() {
|
||||
return (
|
||||
this.state.visible ?
|
||||
<ScaleMenu />
|
||||
<ScaleMenu locale={locale} />
|
||||
:
|
||||
undefined
|
||||
)
|
||||
@@ -21,8 +23,8 @@ export default class App extends Component {
|
||||
useNui("visible", (eventData) => {
|
||||
this.setState({visible: eventData.data})
|
||||
})
|
||||
useNui('visible_check', () => {
|
||||
callNui('visible_check_cb', this.state.visible)
|
||||
callNui('getLocale', {}, (eventData) => {
|
||||
locale = eventData
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useNui, callNui } from '../utils/FiveM';
|
||||
|
||||
const ScaleMenu = () => {
|
||||
const ScaleMenu = ( { locale } ) => {
|
||||
// State for current scale value
|
||||
const [currentScale, setCurrentScale] = useState(1.0);
|
||||
const [minScale, setMinScale] = useState(0.1);
|
||||
@@ -58,16 +58,16 @@ const ScaleMenu = () => {
|
||||
|
||||
return (
|
||||
<div className="absolute top-1/2 right-2.5 transform -translate-y-1/2 bg-[#1A1A1A] border-[1px] border-white/50 rounded-xl px-8 py-7 min-w-[320px] max-w-[320px] font-sans animate-[modalFadeIn_0.4s_cubic-bezier(0.16,1,0.3,1)_forwards] opacity-0 shadow-2xl">
|
||||
<h2 className="text-center mb-8 text-white text-xl font-medium tracking-tight leading-tight bg-gradient-to-br from-white to-gray-300 bg-clip-text text-transparent">Height Scale</h2>
|
||||
<h2 className="text-center mb-8 text-white text-xl font-medium tracking-tight leading-tight bg-gradient-to-br from-white to-gray-300 bg-clip-text text-transparent">{locale["height_scale"]}</h2>
|
||||
|
||||
<Item label="Info" value="When entering and exiting a vehicle, the scale will be reset to 1.0." />
|
||||
<Item label={locale["info"]} value={locale["info_value"]} />
|
||||
|
||||
<Item label="Notice" value="When changing terrain you may notice sudden scale adjustments." />
|
||||
<Item label={locale["notice"]} value={locale["notice_value"]} />
|
||||
|
||||
|
||||
<div className="mb-8">
|
||||
<label className="flex justify-between items-center mb-4 text-sm text-white font-medium tracking-tight">
|
||||
<span>Current Scale</span>
|
||||
<span>{locale["current_scale"]}</span>
|
||||
<span className="text-white font-bold text-sm py-1.5 px-3.5 rounded-lg border border-white/50 ">
|
||||
{currentScale}
|
||||
</span>
|
||||
@@ -122,7 +122,7 @@ const ScaleMenu = () => {
|
||||
</div>
|
||||
|
||||
<div className="text-center mb-6 text-xs text-gray-200 font-medium bg-white/5 px-4.5 py-2.5 rounded-lg border border-white/50 backdrop-blur-sm transition-all duration-200 ease-out hover:bg-white/8">
|
||||
Range: {minScale} - {maxScale}
|
||||
{locale["range"]}: {minScale} - {maxScale}
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 justify-center mt-8">
|
||||
@@ -130,13 +130,13 @@ const ScaleMenu = () => {
|
||||
className="px-7 py-1.5 rounded-md cursor-pointer text-sm font-medium transition-all duration-300 ease-out w-full text-white relative overflow-hidden tracking-tight bg-white/5 text-gray-300 border border-white/50 hover:text-white hover:border-white/15"
|
||||
onClick={handleClose}
|
||||
>
|
||||
Close
|
||||
{locale["close"]}
|
||||
</button>
|
||||
<button
|
||||
className="px-7 py-1.5 rounded-md cursor-pointer text-sm font-medium transition-all duration-300 ease-out text-black w-full relative overflow-hidden tracking-tight bg-white border border-white/50 hover:bg-white/80 hover:border-white/15"
|
||||
onClick={handleSave}
|
||||
>
|
||||
Apply
|
||||
{locale["apply"]}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -26,31 +26,21 @@ function useNui(action, handler) {
|
||||
addDebugLog(`Current handlers for ${action}: ${handlers.get(action).length}`)
|
||||
}
|
||||
|
||||
function callNui(action, data) {
|
||||
addDebugLog(`Calling NUI action: ${action}`, data)
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
fetch(`https://${GetParentResourceName()}/${action}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=UTF-8'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
.then(resp => resp.json())
|
||||
.then(resp => {
|
||||
addDebugLog(`NUI response received for ${action}`, resp)
|
||||
resolve(resp)
|
||||
})
|
||||
.catch(error => {
|
||||
addDebugLog(`NUI call error for ${action}: ${error.message}`)
|
||||
reject(error)
|
||||
})
|
||||
} catch (error) {
|
||||
addDebugLog(`NUI call failed for ${action}: ${error.message}`)
|
||||
reject(error)
|
||||
function callNui(action, data, handler) {
|
||||
fetch(`https://${GetParentResourceName()}/${action}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=UTF-8'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
}).then(resp => resp.json()).then(resp => {
|
||||
|
||||
if (handler !== undefined) {
|
||||
handler(resp);
|
||||
}
|
||||
})
|
||||
}).catch(error => {
|
||||
console.error(`Error in NUI event: ${action}`, error);
|
||||
});
|
||||
}
|
||||
|
||||
// Add initial debug log
|
||||
|
||||
Reference in new issue
Block a user