Files
BlackFruit-UI/js/i18n.js
yiqiu 2b31442085
All checks were successful
continuous-integration/drone/push Build is passing
style: 重新设计语言切换按钮 — SVG 地球图标 + CN/EN 双标签
- emoji 🌐 替换为精致 SVG 线条地球图标
- 按钮改为圆角胶囊样式,透明底 + 细边框
- 显示 CN/EN 双标签(当前语言高亮,另一个淡显)
- hover 时整体变蓝色主题色
2026-03-18 19:02:02 +08:00

356 lines
18 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* i18n.js — 轻量国际化引擎
* 用法:给 HTML 元素加 data-i18n="key" 属性,调用 i18n.setLang('en') 切换
*/
(function () {
'use strict';
var i18n = {};
// 语言字典
i18n.dict = {
zh: {
// === Header ===
nav_console: '控制台',
nav_login: '登录',
nav_register: '立即注册',
lang_label: 'CN',
// === Banner 占位 ===
banner_tag_cloud: '云计算',
banner_tag_value: '高性价比',
banner_title_1: '中小企业的云计算底座',
banner_desc_1: '主题云聚焦中小企业的数智化转型进程,以技术和数据为驱动,以产品和场景为载体,专注于打磨云上业务服务能力,助力中小企业全面业务上云演化。',
banner_btn: '立即查看',
banner_tag_elastic: '弹性伸缩',
banner_tag_stable: '安全稳定',
banner_title_2: '企业级云服务解决方案',
banner_desc_2: '提供高性能、高可用的云计算服务,支持弹性伸缩,按需付费,助力企业数字化转型。',
banner_tag_global: '全球部署',
banner_title_3: '全球云基础设施',
banner_desc_3: '覆盖全球20+地区60+可用区500+CDN节点为您提供低延迟、高可用的云服务体验。',
// === Banner 下方卡片 ===
promo_new_user: '新用户最低可<span class="highlight">5折</span>优惠',
promo_new_user_desc: '无数个人用户的共同选择',
promo_domain: '域名<span class="highlight">低至9元</span>起',
promo_domain_desc: '优选主流域名注册服务',
promo_cps: '推广最高<span class="highlight">35%</span>佣金',
promo_cps_desc: '多种产品高额返佣',
promo_register: '注册送<span class="highlight">2000元</span>礼包',
promo_register_desc: '免费注册领取专属礼包',
// === 热销产品 ===
hot_title: '热销产品推荐',
hot_subtitle: '高性价比云服务器,助力您的业务快速上云',
badge_hot: '热销',
badge_recommend: '推荐',
badge_promo: '特惠',
badge_new: '上新',
badge_defense: '高防',
btn_buy: '立即购买',
price_limit: '限购1台',
btn_more_products: '查看更多产品',
btn_collapse_products: '收起产品',
// === 产品名 ===
product_hk_elastic: '香港弹性云',
product_us_defense: '美国高防云',
product_sg_cn2: '新加坡CN2云',
product_jp_bgp: '日本BGP云',
product_kr_cn2: '韩国CN2云',
product_cn_bgp: '国内BGP云',
product_zj_defense: '镇江高防云',
product_sq_bgp: '宿迁BGP云',
// === 产品描述 ===
product_desc_storage: '稳定、安全、高效、易用,可存储任意类型和形式的非结构化数据',
product_desc_scale: '稳定、安全、高效、易用,可承载任意规模和形式的非结构化数据',
product_desc_kr: '低延迟、高速度,适合游戏、视频等对网络质量要求高的业务',
product_desc_cn: '多线BGP接入覆盖全国各地区访问速度快稳定性高',
product_desc_defense: 'T级防御能力有效抵御各类DDoS攻击保障业务连续性',
product_desc_sq: '全新BGP线路性价比极高适合个人站长及中小企业',
// === 解决方案 ===
solution_title: '全场景全栈解决方案',
solution_desc: '专业构架师针对丰富的业务场景,为千行百业构建稳定、易用的高性价比解决方案。',
tab_ecommerce: '电商',
tab_finance: '金融',
tab_game: '游戏',
tab_travel: '文旅',
tab_education: '教育',
tab_medical: '医疗',
tab_agriculture: '农业',
solution_ecommerce_title: '电商解决方案',
solution_ecommerce_sub: '应对高并发、大促等复杂场景',
solution_ecommerce_p1: '提供完整的电商云解决方案,有效应对大促、秒杀等高并发场景,保障系统稳定运行。',
solution_ecommerce_p2: '通过弹性扩容、智能调度等技术手段,助力电商平台快速响应业务需求,提升用户体验。',
solution_ecommerce_p3: '支持多种营销活动场景,实现营销创新与业务增收的双重目标。',
solution_finance_title: '金融解决方案',
solution_finance_sub: '安全可靠的金融级云服务',
solution_finance_p1: '为金融机构提供安全可靠的云计算基础设施,满足金融行业严格的监管要求和安全标准。',
solution_finance_p2: '助力金融机构打造面向垂直场景的创新金融产品,实现与用户之间的高效触达。',
solution_finance_p3: '提供风险控制、数据分析、智能客服等全方位技术支持,推动金融科技创新。',
solution_game_title: '游戏解决方案',
solution_game_sub: '低延迟、高并发的游戏云平台',
solution_game_p1: '构建高质量、全方位、深度体验的游戏云平台,提供低延迟、高并发的游戏运行环境。',
solution_game_p2: '支持游戏快速部署、弹性扩容,满足各类游戏场景需求。',
solution_game_p3: '通过智能运维、数据分析等技术手段,提升游戏研发效率,优化玩家游戏体验。',
solution_travel_title: '文旅解决方案',
solution_travel_sub: '科技赋能智慧文旅',
solution_travel_p1: '通过"科技+文化旅游"的深度融合创新及落地应用,推动文旅行业全面信息化、智慧化发展。',
solution_travel_p2: '提供智慧景区、智慧酒店、智慧旅行社等全场景解决方案,实现景区管理数字化、游客服务智能化。',
solution_travel_p3: '利用大数据、人工智能等技术,优化旅游资源配置,提升游客体验。',
solution_education_title: '教育解决方案',
solution_education_sub: '打造云时代教育新模式',
solution_education_p1: '实现教育数据互联互通、教学过程可视化、师生互动高交互的云上教育环境,打造云时代教育治理新模式。',
solution_education_p2: '提供在线课堂、智慧校园、教育管理等全方位解决方案,支持大规模在线教学和混合式教学模式。',
solution_education_p3: '通过人工智能、大数据等技术,实现个性化教学和精准教学评估。',
solution_medical_title: '医疗解决方案',
solution_medical_sub: '构建数字化医疗生态',
solution_medical_p1: '协助医疗机构打造医疗数据资源共享、医疗资源再利用、医疗知识再生产的数字化医疗生态循环体系。',
solution_medical_p2: '提供远程医疗、智慧医院、医疗影像云等解决方案,支持医疗数据安全存储和高效分析。',
solution_medical_p3: '通过云计算、人工智能等技术,辅助临床决策,提升医疗服务质量和效率。',
solution_agriculture_title: '农业解决方案',
solution_agriculture_sub: '推动智慧农业转型升级',
solution_agriculture_p1: '助力农业企业构建智慧农业生产服务体系,提升农业精细化种植与智能化管理水平。',
solution_agriculture_p2: '提供农业物联网、农产品溯源、智能灌溉等全链条解决方案,实现农业生产全过程数字化监控和管理。',
solution_agriculture_p3: '通过大数据分析和人工智能技术,优化种植方案,提高农作物产量和品质。',
solution_learn_more: '了解详情',
// === 基础设施 ===
infra_title: '安全合规、高速稳定的基础设施',
infra_regions: '国家地理区域',
infra_zones: '可用区',
infra_cdn: '全球CDN节点',
infra_ddos: '可承载DDOS攻击',
// === 荣誉 ===
honor_title: '企业资质与荣誉',
honor_subtitle: '实体企业,资质齐全,技术独立<br>国三资资质证书+增值电信业务经营许可证(ISP资质)+其他资质齐全,可帮助用户办理ICP备案、公安备案等',
// === 新闻 ===
news_title: '新动向,新机遇',
news_desc: '最新发展动态、最热行业资讯,与主题云一起见证云时代精彩瞬间',
news_announcement: '官方公告',
news_info: '新闻资讯',
news_more: '更多',
// === 登录菜单 ===
menu_account: '账户信息',
menu_unpaid: '未付款订单',
menu_ticket: '我的工单',
menu_logout: '退出账户',
menu_not_certified: '未实名',
menu_certified: '已实名',
},
en: {
// === Header ===
nav_console: 'Console',
nav_login: 'Login',
nav_register: 'Sign Up',
lang_label: 'EN',
// === Banner 占位 ===
banner_tag_cloud: 'Cloud',
banner_tag_value: 'Cost-effective',
banner_title_1: 'Cloud Foundation for SMEs',
banner_desc_1: 'Focused on digital transformation for small and medium enterprises, driven by technology and data, delivering reliable cloud services to accelerate your business growth.',
banner_btn: 'Learn More',
banner_tag_elastic: 'Auto-scaling',
banner_tag_stable: 'Secure & Stable',
banner_title_2: 'Enterprise Cloud Solutions',
banner_desc_2: 'High-performance, highly available cloud computing with elastic scaling and pay-as-you-go pricing to drive digital transformation.',
banner_tag_global: 'Global Deploy',
banner_title_3: 'Global Cloud Infrastructure',
banner_desc_3: 'Over 20 regions, 60+ availability zones, 500+ CDN nodes worldwide for low-latency, highly available cloud services.',
// === Banner 下方卡片 ===
promo_new_user: 'New users get up to <span class="highlight">50% off</span>',
promo_new_user_desc: 'Trusted by millions of individual users',
promo_domain: 'Domains from <span class="highlight">$1.29</span>',
promo_domain_desc: 'Premium domain registration services',
promo_cps: 'Earn up to <span class="highlight">35%</span> commission',
promo_cps_desc: 'High commissions across all products',
promo_register: 'Get <span class="highlight">$300</span> welcome bonus',
promo_register_desc: 'Sign up and claim your exclusive bonus',
// === 热销产品 ===
hot_title: 'Best-Selling Products',
hot_subtitle: 'High-performance cloud servers to accelerate your business',
badge_hot: 'Hot',
badge_recommend: 'Recommended',
badge_promo: 'Deal',
badge_new: 'New',
badge_defense: 'DDoS',
btn_buy: 'Buy Now',
price_limit: 'Limit 1',
btn_more_products: 'View More Products',
btn_collapse_products: 'Collapse',
// === 产品名 ===
product_hk_elastic: 'Hong Kong Elastic Cloud',
product_us_defense: 'US DDoS-Protected Cloud',
product_sg_cn2: 'Singapore CN2 Cloud',
product_jp_bgp: 'Japan BGP Cloud',
product_kr_cn2: 'Korea CN2 Cloud',
product_cn_bgp: 'China BGP Cloud',
product_zj_defense: 'Zhenjiang DDoS Cloud',
product_sq_bgp: 'Suqian BGP Cloud',
// === 产品描述 ===
product_desc_storage: 'Stable, secure, efficient, and user-friendly for storing unstructured data of any type',
product_desc_scale: 'Stable, secure, efficient, and user-friendly for workloads of any scale',
product_desc_kr: 'Low latency, high speed — ideal for gaming, video, and latency-sensitive applications',
product_desc_cn: 'Multi-line BGP access, nationwide coverage, fast speed and high stability',
product_desc_defense: 'T-level defense capability, effectively resisting various DDoS attacks',
product_desc_sq: 'Brand new BGP lines, extremely cost-effective, ideal for individual webmasters and SMEs',
// === 解决方案 ===
solution_title: 'Full-Stack Solutions for Every Scenario',
solution_desc: 'Professional architects build stable, easy-to-use, cost-effective solutions for all industries.',
tab_ecommerce: 'E-commerce',
tab_finance: 'Finance',
tab_game: 'Gaming',
tab_travel: 'Tourism',
tab_education: 'Education',
tab_medical: 'Healthcare',
tab_agriculture: 'Agriculture',
solution_ecommerce_title: 'E-commerce Solutions',
solution_ecommerce_sub: 'Handle high concurrency and flash sales',
solution_ecommerce_p1: 'Complete e-commerce cloud solutions for flash sales, promotions, and high-concurrency scenarios.',
solution_ecommerce_p2: 'Elastic scaling and intelligent scheduling to help e-commerce platforms respond quickly.',
solution_ecommerce_p3: 'Support various marketing scenarios to drive innovation and revenue growth.',
solution_finance_title: 'Financial Solutions',
solution_finance_sub: 'Secure and reliable financial-grade cloud',
solution_finance_p1: 'Secure cloud computing infrastructure that meets strict regulatory requirements.',
solution_finance_p2: 'Help financial institutions build innovative products for vertical scenarios.',
solution_finance_p3: 'Risk control, data analytics, and intelligent customer service support.',
solution_game_title: 'Gaming Solutions',
solution_game_sub: 'Low-latency, high-concurrency gaming platform',
solution_game_p1: 'Build high-quality gaming cloud platforms with low latency and high concurrency.',
solution_game_p2: 'Rapid deployment and elastic scaling for all game types.',
solution_game_p3: 'Intelligent operations and data analytics to optimize player experience.',
solution_travel_title: 'Tourism Solutions',
solution_travel_sub: 'Technology-powered smart tourism',
solution_travel_p1: 'Deep integration of technology and cultural tourism for industry-wide digital transformation.',
solution_travel_p2: 'Smart scenic areas, smart hotels, and smart travel agencies.',
solution_travel_p3: 'Big data and AI to optimize tourism resources and enhance visitor experience.',
solution_education_title: 'Education Solutions',
solution_education_sub: 'Cloud-era education innovation',
solution_education_p1: 'Cloud-based education with data interconnection, visual teaching, and interactive collaboration.',
solution_education_p2: 'Online classrooms, smart campuses, and education management at scale.',
solution_education_p3: 'AI and big data for personalized teaching and precise assessment.',
solution_medical_title: 'Healthcare Solutions',
solution_medical_sub: 'Building a digital medical ecosystem',
solution_medical_p1: 'Help medical institutions build a digital healthcare ecosystem for data sharing.',
solution_medical_p2: 'Telemedicine, smart hospitals, and medical imaging cloud solutions.',
solution_medical_p3: 'Cloud computing and AI to assist clinical decisions and improve care quality.',
solution_agriculture_title: 'Agriculture Solutions',
solution_agriculture_sub: 'Driving smart agriculture transformation',
solution_agriculture_p1: 'Build smart agricultural production service systems for precision farming.',
solution_agriculture_p2: 'IoT, traceability, and smart irrigation across the entire agricultural chain.',
solution_agriculture_p3: 'Big data and AI to optimize planting plans and improve crop yield.',
solution_learn_more: 'Learn More',
// === 基础设施 ===
infra_title: 'Secure, Compliant & High-Speed Infrastructure',
infra_regions: 'Geographic Regions',
infra_zones: 'Availability Zones',
infra_cdn: 'Global CDN Nodes',
infra_ddos: 'DDoS Protection Capacity',
// === 荣誉 ===
honor_title: 'Certifications & Awards',
honor_subtitle: 'Established enterprise with complete certifications and independent technology<br>ISP license, MIIT certification, and various qualifications to assist with ICP and public security filings',
// === 新闻 ===
news_title: 'Latest News & Opportunities',
news_desc: 'Stay updated with the latest developments and industry insights',
news_announcement: 'Announcements',
news_info: 'News',
news_more: 'More',
// === 登录菜单 ===
menu_account: 'Account',
menu_unpaid: 'Unpaid Orders',
menu_ticket: 'My Tickets',
menu_logout: 'Logout',
menu_not_certified: 'Unverified',
menu_certified: 'Verified',
}
};
/**
* 获取当前语言
*/
i18n.getLang = function () {
return localStorage.getItem('lang') || 'zh';
};
/**
* 设置语言并更新页面
*/
i18n.setLang = function (lang) {
if (!i18n.dict[lang]) return;
localStorage.setItem('lang', lang);
i18n.apply(lang);
};
/**
* 切换语言 (zh ↔ en)
*/
i18n.toggle = function () {
var current = i18n.getLang();
i18n.setLang(current === 'zh' ? 'en' : 'zh');
};
/**
* 应用语言到页面
*/
i18n.apply = function (lang) {
lang = lang || i18n.getLang();
var dict = i18n.dict[lang];
if (!dict) return;
// 遍历所有 data-i18n 元素
var els = document.querySelectorAll('[data-i18n]');
for (var idx = 0; idx < els.length; idx++) {
var el = els[idx];
var key = el.getAttribute('data-i18n');
if (dict[key] !== undefined) {
// 对包含 HTML 的内容用 innerHTML如 <span class="highlight">
if (dict[key].indexOf('<') !== -1) {
el.innerHTML = dict[key];
} else {
el.textContent = dict[key];
}
}
}
// 更新 html lang 属性
document.documentElement.lang = lang === 'zh' ? 'zh-CN' : 'en';
// 更新语言切换按钮
var langTexts = document.querySelectorAll('.lang-text');
var langAlts = document.querySelectorAll('.lang-alt');
for (var i = 0; i < langTexts.length; i++) {
langTexts[i].textContent = lang === 'zh' ? 'CN' : 'EN';
}
for (var j = 0; j < langAlts.length; j++) {
langAlts[j].textContent = lang === 'zh' ? 'EN' : 'CN';
}
};
// 暴露到全局
window.i18n = i18n;
// DOM 就绪时自动应用
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function () { i18n.apply(); });
} else {
i18n.apply();
}
})();