汉晶添加中英文翻译
This commit is contained in:
120
hanJing/js/technicalSupport.js
Normal file
120
hanJing/js/technicalSupport.js
Normal file
@@ -0,0 +1,120 @@
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const langData = {
|
||||
zh: {
|
||||
btn: "English",
|
||||
logo: "../imgs/svg/logo.svg",
|
||||
title: "深圳汉晶电子信息有限公司",
|
||||
// 顶部
|
||||
topBannerTitle: "技术支持",
|
||||
topBannerDesc: "我们为您的项目提供技术指导。我们的技术销售代表和产品专家可以从技术角度解答您关于产品的问题",
|
||||
// 三大服务
|
||||
service: [
|
||||
{
|
||||
title: "技术咨询",
|
||||
desc: "提供芯片设计前的需求分析、技术选型、系统架构建议。",
|
||||
btn: "提交服务帮助"
|
||||
},
|
||||
{
|
||||
title: "定制化开发",
|
||||
desc: "根据客户的特定需求,提供个性化定制的芯片设计服务,确保项目的高效实施。",
|
||||
btn: "定制需求"
|
||||
},
|
||||
{
|
||||
title: "产品维护与升级",
|
||||
desc: "提供持续的技术支持,定期为客户的芯片产品提供性能优化与功能升级。",
|
||||
btn: "立即升级"
|
||||
}
|
||||
],
|
||||
emailLeftTitle: "我们准备好了",
|
||||
emailLeftText: "如果您有更多的需求,请联系我们",
|
||||
topBannerBG: "../imgs/svg/技术支持图.svg",
|
||||
},
|
||||
en: {
|
||||
btn: "简体中文",
|
||||
logo: "../imgs/svg/logo_en.svg",
|
||||
title: "SZHJ Electronic Information Co., Ltd",
|
||||
// 顶部
|
||||
topBannerTitle: "Technical Support",
|
||||
topBannerDesc: "We provide technical guidance for your projects. Our technical sales representatives and product experts can answer your product questions from a technical perspective.",
|
||||
// 三大服务
|
||||
service: [
|
||||
{
|
||||
title: "Technical Consulting",
|
||||
desc: "Provide pre-design requirement analysis, technical selection, and system architecture advice for chip design.",
|
||||
btn: "Submit Service Request"
|
||||
},
|
||||
{
|
||||
title: "Customized Development",
|
||||
desc: "Provide personalized chip design services according to customer needs, ensuring efficient project implementation.",
|
||||
btn: "Customization Request"
|
||||
},
|
||||
{
|
||||
title: "Product Maintenance & Upgrade",
|
||||
desc: "Provide continuous technical support and regularly optimize and upgrade customer chip products.",
|
||||
btn: "Upgrade Now"
|
||||
}
|
||||
],
|
||||
emailLeftTitle: "We're ready.",
|
||||
emailLeftText: "If you have more needs, please contact us!",
|
||||
topBannerBG: "../imgs/technology/technicalSupport_en.svg",
|
||||
}
|
||||
};
|
||||
|
||||
let currentLang = localStorage.getItem('siteLang') || "zh";
|
||||
|
||||
function applyLang(lang) {
|
||||
const data = langData[lang];
|
||||
|
||||
// logo
|
||||
document.getElementById("footerLogo").src = data.logo;
|
||||
document.querySelector('.footerBoxRightTitle').textContent = data.title;
|
||||
// 页面标题
|
||||
document.title = data.title;
|
||||
|
||||
// 顶部标题和描述
|
||||
document.querySelector('.topBannerLeftTitle p:nth-child(1)').textContent = data.topBannerTitle;
|
||||
document.querySelector('.topBannerLeftTitle p:nth-child(2)').textContent = data.topBannerDesc;
|
||||
|
||||
// 三大服务
|
||||
const serviceBoxes = document.querySelectorAll('.bannerBox > .bannerLeft, .bannerBox > .bannerRight');
|
||||
data.service.forEach((item, idx) => {
|
||||
if (serviceBoxes[idx]) {
|
||||
serviceBoxes[idx].querySelector('.title').textContent = item.title;
|
||||
serviceBoxes[idx].querySelector('.problem').textContent = item.desc;
|
||||
serviceBoxes[idx].querySelector('.report').childNodes[0].nodeValue = item.btn + " ";
|
||||
}
|
||||
});
|
||||
|
||||
// 邮箱区
|
||||
document.querySelector(".emailLeftTitle").textContent = data.emailLeftTitle;
|
||||
document.querySelector(".emailLeftText").textContent = data.emailLeftText;
|
||||
|
||||
// 按钮文本
|
||||
document.getElementById("lang-toggle").textContent = data.btn;
|
||||
// 背景图
|
||||
document.querySelector('.topBanner').style.backgroundImage = `url(${data.topBannerBG})`;
|
||||
// 英文样式调整(如有需要可扩展)
|
||||
if (lang === 'en') {
|
||||
document.querySelector('.topBannerLeftTitle p:nth-child(1)').classList.add('en');
|
||||
document.querySelector('.topBannerLeftTitle p:nth-child(2)').classList.add('en');
|
||||
} else {
|
||||
document.querySelector('.topBannerLeftTitle p:nth-child(1)').classList.remove('en');
|
||||
document.querySelector('.topBannerLeftTitle p:nth-child(2)').classList.remove('en');
|
||||
}
|
||||
}
|
||||
|
||||
function handleLangToggle() {
|
||||
currentLang = currentLang === "zh" ? "en" : "zh";
|
||||
localStorage.setItem('siteLang', currentLang);
|
||||
applyLang(currentLang);
|
||||
}
|
||||
|
||||
// 初始化
|
||||
applyLang(currentLang);
|
||||
|
||||
// 事件绑定
|
||||
document.getElementById("lang-toggle").addEventListener("click", handleLangToggle);
|
||||
document.getElementById("lang-toggle").addEventListener("keydown", e => {
|
||||
if (e.key === "Enter" || e.key === " ") handleLangToggle();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user