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

[BUG] No Menu Translation #359

Open
CxCore-xyz opened this issue Jun 17, 2024 · 3 comments
Open

[BUG] No Menu Translation #359

CxCore-xyz opened this issue Jun 17, 2024 · 3 comments
Labels
bug Something isn't working Stale

Comments

@CxCore-xyz
Copy link

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 CxCore-xyz added the bug Something isn't working label Jun 17, 2024
@CxCore-xyz CxCore-xyz changed the title [BUG] Not Menu Translation [BUG] No Menu Translation Jun 17, 2024
@CxCore-xyz
Copy link
Author

image

@movohou
Copy link

movohou commented Aug 1, 2024

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);
});

Copy link

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

@github-actions github-actions bot added the Stale label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

2 participants