qb-garages icon indicating copy to clipboard operation
qb-garages copied to clipboard

[BUG] No Menu Translation

Open CxCore-xyz opened this issue 1 year ago • 3 comments

Hello theres no way to translate the Fuel,Engine and Body in the menu if you translate it true js and client it starts to give errors with engine and etc

CxCore-xyz avatar Jun 17 '24 17:06 CxCore-xyz

image

CxCore-xyz avatar Jun 17 '24 17:06 CxCore-xyz

Hello! I'm glad to help you solve this problem. It's very simple. You just need to add to the top of your script.js file

const translationMap = {
    "fuel": "燃料",
    "engine": "引擎",
    "body": "车身"
};

Then copy the code I gave you and search for ["fuel", "engine", "body"] and replace the entire code

["fuel", "engine", "body"].forEach((statLabel) => {
            const stat = document.createElement("div");
            stat.classList.add("stat");
            const label = document.createElement("div");
            label.classList.add("label");
            label.textContent = translationMap[statLabel] || statLabel.charAt(0).toUpperCase() + statLabel.slice(1); 
            // 使用 translationMap 进行翻译,如果没有对应的翻译,则使用原字符并首字母大写
            stat.appendChild(label);
            const progressBar = document.createElement("div");
            progressBar.classList.add("progress-bar");
            const progress = document.createElement("span");
            const progressText = document.createElement("span");
            progressText.classList.add("progress-text");
            const percentage = (v[statLabel] / maxValues[statLabel]) * 100;
            progress.style.width = percentage + "%";
            progressText.textContent = Math.round(percentage) + "%";

            if (percentage >= 75) {
                progress.classList.add("bar-green");
            } else if (percentage >= 50) {
                progress.classList.add("bar-yellow");
            } else {
                progress.classList.add("bar-red");
            }

            progressBar.appendChild(progressText);
            progressBar.appendChild(progress);
            stat.appendChild(progressBar);
            stats.appendChild(stat);
            vehicleItem.appendChild(stats);
});

movohou avatar Aug 01 '24 09:08 movohou

This issue has had 60 days of inactivity & will close within 7 days

github-actions[bot] avatar Sep 30 '24 15:09 github-actions[bot]