汉晶添加中英文翻译

This commit is contained in:
2025-05-08 14:56:06 +08:00
parent bd38cf7e2d
commit 3923e4df10
38 changed files with 1431 additions and 214 deletions

View File

@@ -203,6 +203,182 @@ container.addEventListener('touchend', (e) => {
// 开始自动播放
startAutoPlay();
// --------------------------------
const langData = {
zh: {
nav: {
home: "首页",
business: "主营业务",
products: "产品案例",
support: "技术支持",
future: "展望未来",
about: "关于我们"
},
btn: "English",
logo: "./imgs/svg/logo.svg",
bannerBg: "../imgs/svg/背景纹(大).svg",
bannerListImgs: [
"../imgs/home/mainBusiness.png",
"../imgs/home/aboutUs.png",
],
CarouselImgs: [
"./imgs/home/Y100.jpg",
"./imgs/home/S6PRO.jpg",
],
carouselText: "产品详情",
title: "深圳汉晶电子信息有限公司",
bannerBottom2Title: "为什么选择汉晶?",
bannerBottomListOneTitle: "IC设计全生命周期一站式覆盖",
bannerBottomListTwoTitle: "独特的低功耗设计,让芯片更有竞争力",
bannerBottomListThreeTitle: "有稳定的芯片制造商合作关系",
bannerBottomListFourTitle: "流片均一版成功即流片成功率100%,助力客户赢得市场",
bannertopTitle: "芯片设计技术服务",
bannertopText: "我们公司提供全方位的芯片设计技术服务涵盖从需求讨论、系统设计、逻辑设计、FPGA原型验证到最终的芯片制造、测试与验证等各个环节。我们采用行业领先的工具和技术确保芯片的性能、功耗、稳定性都能满足客户需求。",
bannerletfTextTitle: "Y100 服务器芯片",
bannerletfTextTitle2: "S6PRO 运算加速芯片",
bannerBottomTextTitle: "我们的目标",
bannerBottomTextText: "汇聚人才,共同创造突破性技术,为更加智能、更加安全、更有保障的科技世界保驾护航。",
newBottomTitle: "研发团队",
newBottomText: "研究生学历",
emailLeftTitle: "我们准备好了",
emailLeftText: "如果您有更多的需求,请联系我们",
},
en: {
nav: {
home: "Home",
business: "Business",
products: "Products",
support: "Support",
future: "Future",
about: "About Us"
},
btn: "简体中文",
logo: "./imgs/svg/logo_en.svg",
bannerBg: "../imgs/svg/bg_en.svg",
bannerListImgs: [
"../imgs/home/mainBusiness_en.png",
"../imgs/home/aboutUs_en.png",
],
CarouselImgs: [
"./imgs/home/Y100_en.jpg",
"./imgs/home/S6PRO_en.jpg",
],
carouselText: "Product Details",
title: "SZHJ Electronic Information Co., Ltd",
bannerBottom2Title: "Why Hanjing?",
bannerBottomListOneTitle: "One-stop coverage of the entire IC design life cycle",
bannerBottomListTwoTitle: "Unique low-power design makes the chip more competitive",
bannerBottomListThreeTitle: "Stable relationships with chip makers",
bannerBottomListFourTitle: "Successful flow of the first version of the film, i.e., 100% success rate of the flow of the film, to help customers win the market",
bannertopTitle: "Chip Design Technology Services",
bannertopText: "Our company provides a full range of chip design technology services, covering all aspects from requirements discussion, system design, logic design, FPGA prototyping, to final chip manufacturing, testing and verification. We use industry-leading tools and technologies to ensure that the performance, power consumption, and stability of the chip meets customer requirements.",
bannerletfTextTitle: "Y100 Server Chips",
bannerletfTextTitle2: "S6PRO computing accelerator chip",
bannerBottomTextTitle: "Our Goals",
bannerBottomTextText: "Bringing together talents to create breakthrough technologies for a smarter, safer and more secure technological world.",
newBottomTitle: "R&D Team",
newBottomText: "postgraduate education",
emailLeftTitle: "We're ready.",
emailLeftText: "If you have more needs, please contact us!",
}
};
let currentLang = localStorage.getItem('siteLang') || "zh";
function applyLang(lang) {
const data = langData[lang];
// 导航文本
document.getElementById("nav-home").textContent = data.nav.home;
document.getElementById("nav-business").textContent = data.nav.business;
document.getElementById("nav-products").textContent = data.nav.products;
document.getElementById("nav-support").textContent = data.nav.support;
document.getElementById("nav-future").textContent = data.nav.future;
document.getElementById("nav-about").textContent = data.nav.about;
// 按钮文本
document.getElementById("lang-toggle").textContent = data.btn;
// logo
document.getElementById("logo-img").src = data.logo;
document.getElementById("footerLogo").src = data.logo;
// 轮播图图片全部替换(包括克隆节点)
document.querySelectorAll('img[alt="S6PRO"]').forEach(img => {
img.src = data.CarouselImgs[1];
});
document.querySelectorAll('img[alt="Y100"]').forEach(img => {
img.src = data.CarouselImgs[0];
});
// 轮播图详情按钮文本全部切换
document.querySelectorAll('.carouselText').forEach(span => {
span.textContent = data.carouselText;
});
// 其它页面内容
document.querySelector('.bannerBottom2Title').textContent = data.bannerBottom2Title;
document.querySelector('.bannerBottomListOneTitle').textContent = data.bannerBottomListOneTitle;
document.querySelector('.bannerBottomListTwoTitle').textContent = data.bannerBottomListTwoTitle;
document.querySelector('.bannerBottomListThreeTitle').textContent = data.bannerBottomListThreeTitle;
document.querySelector('.bannerBottomListFourTitle').textContent = data.bannerBottomListFourTitle;
document.querySelector('.bannertopTitle').textContent = data.bannertopTitle;
document.querySelector('.bannertopText').textContent = data.bannertopText;
document.querySelector('.bannerletfTextTitle').textContent = data.bannerletfTextTitle;
document.querySelector('.bannerBottomTextTitle').textContent = data.bannerBottomTextTitle;
document.querySelector('.bannerBottomTextText').textContent = data.bannerBottomTextText;
document.querySelector('.newBottomTitle').textContent = data.newBottomTitle;
document.querySelector('.newBottomText').textContent = data.newBottomText;
document.querySelector('.emailLeftTitle').textContent = data.emailLeftTitle;
document.querySelector('.emailLeftText').textContent = data.emailLeftText;
document.querySelector('.footerBoxRightTitle').textContent = data.title;
document.querySelector('.title').textContent = data.title;
document.getElementById("bannerletfTextTitle2").textContent = data.bannerletfTextTitle2;
if (lang === 'en') {
document.querySelector('.textBox').classList.add('en');
} else {
document.querySelector('.textBox').classList.remove('en');
}
// bannerBottomList 背景图片
const bannerListClasses = [
".bannertop",
".bannerBottom",
];
bannerListClasses.forEach((cls, idx) => {
const el = document.querySelector(cls);
if (el) {
el.style.backgroundImage = `url(${data.bannerListImgs[idx]})`;
}
});
}
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();
});
});