-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlanguage.js
More file actions
941 lines (886 loc) · 36.2 KB
/
language.js
File metadata and controls
941 lines (886 loc) · 36.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
const translations = {
en: {
title: "Legacy Lands",
orgTitle: "Commercial Organization",
orgDescription: "A professional software development organization dedicated to creating elegant solutions.",
// 组织成员部分
roles: {
founder: "Founder",
mainplanner: "Main Planner",
planner: "Planner",
maindeveloper: "Main Developer",
developer: "Developer",
mainbuilder: "Main Builder",
builder: "Builder",
minecrafttechnician: "Minecraft Technician",
graphicdesigner: "Graphic Designer"
},
// 使命部分
missionTitle: "Our Mission",
missionSubtitle: "Building the Future, Shaping Legacy",
innovation: {
title: "Innovation",
subtitle: "Pushing Boundaries",
description: "We embrace cutting-edge technologies and innovative approaches to create exceptional gaming experiences. Our passion for exploration drives us to continuously evolve and improve."
},
community: {
title: "Community",
subtitle: "Building Together",
description: "We foster vibrant communities where creativity thrives and lasting connections are formed. Every voice matters in shaping our shared digital worlds."
},
// 联系部分
contactTitle: "Contact Us",
contactSubtitle: "Ready to Collaborate? Let's Connect!",
// Hero section translations
hero: {
badge: "Open Source & Commercial",
title: "Professional Minecraft Complete Production Team",
description: "Full-spectrum Minecraft professional team integrating server development, architectural design, and technical innovation.<br>Specialized in independently developing and operating large-scale immersive civilization simulation servers, while actively contributing to the open-source ecosystem by providing enterprise-grade technical frameworks and professional solutions for Minecraft plugin development.",
viewProjects: "View Our Projects",
github: "GitHub",
stats: {
teamMembers: "Team Members",
majorProjects: "Major Projects",
codeCommits: "Code Commits",
linesOfCode: "Lines of Code"
}
},
// Core business section
coreProjects: {
title: "Our Core Projects",
description: "Two flagship projects that showcase our expertise in modern Minecraft development",
library: {
title: "Legacy Lands Library",
subtitle: "Enterprise-grade Minecraft Server Plugin Development Framework",
description: "An enterprise-grade modular framework specifically designed for Minecraft server plugin development, providing professional development tools and technical support.",
tags: ["Open Source", "Enterprise-grade", "Plugin Development", "Modular Framework"],
button: "Explore Library"
},
server: {
title: "Legacy Lands Server",
subtitle: "Minecraft Civilization Simulation Platform",
description: "An immersive Minecraft server focused on civilization simulation, nation building, and collaborative gameplay experiences for a thriving community.",
tags: ["Commercial", "Multiplayer", "Civilization Building", "Community"],
button: "Join Server"
}
},
qqgroup: {
title: "QQ Group",
description: "Join our community",
button: "1022665227"
},
github: {
title: "GitHub",
description: "Check our projects",
button: "View Projects"
},
founder: {
title: "Founder",
description: "Contact the founder",
button: "Send Email"
},
sponsor: {
title: "Sponsor",
description: "Support our development",
button: "View Sponsors"
},
// 项目部分
library: {
title: "Legacy Lands Library",
description: "Modern Java Library",
tags: ["Framework", "Open Source", "Modern Java"],
button: "View Repository"
},
server: {
title: "Legacy Lands Server",
description: "Main commercial projects",
tags: ["Minecraft Server", "Civilization Simulation"],
button: "Join QQ Group"
},
// 成员技能
skills: {
funding: "Funding",
planning: "Planning",
operationandmaintenance: "Operation and maintenance",
java: "Java",
elixir: "Elixir",
frontend: "Frontend",
backend: "Backend",
bukkit: "Bukkit",
devops: "DevOps",
builder: "Builder",
architectsofvariousstyles: "Architects of various styles",
networktechnology: "Network Technology",
hardwaredevelopment: "Hardware Development"
},
// 使命卡片
heritage: {
title: "Heritage",
subtitle: "Meaningful Legacy",
description: "We create lasting experiences that blend cultural depth with engaging gameplay. Every project carries purpose, leaving a positive impact on players and communities."
},
experience: {
title: "Experience",
subtitle: "Crafted Excellence",
description: "We meticulously design every interaction to create seamless, engaging experiences. From intuitive interfaces to immersive gameplay, quality is in every detail."
},
growth: {
title: "Growth",
subtitle: "Continuous Evolution",
description: "We believe in iterative improvement and learning from every challenge. Our commitment to growth ensures that each project surpasses the last in quality and innovation."
},
opensource: {
title: "Open Source",
subtitle: "Collaborative Innovation",
description: "We contribute to the global developer community by open-sourcing our tools and frameworks. Knowledge sharing accelerates innovation and creates opportunities for everyone."
},
sections: {
mission: "Our Mission",
library: "Legacy Lands Library",
server: "Legacy Lands Server",
contact: "Contact Us"
},
members: {
xiaoliang: {
name: "Xiao Liang",
role: "Founder"
},
feige: {
name: "Fei Ge",
role: "Main Planner"
},
xiaochen: {
name: "Xiao Chen",
role: "Planner"
},
linxi: {
name: "Psyche",
role: "Main Developer"
},
zuijiu: {
name: "Zui Jiu",
role: "Developer"
},
neglectdream: {
name: "NeglectDream",
role: "Developer, Technician"
},
autuo: {
name: "Autuo",
role: "Technician"
},
cuixuan: {
name: "Cui Xuan",
role: "Graphic Designer"
},
duya: {
name: "Du Ya",
role: "Main Builder"
},
heiyu: {
name: "Hei Yu",
role: "Builder"
}
},
sponsors: {
title: "Our Sponsors",
subtitle: "Thank you for your support!",
search: "Search sponsors...",
tiers: {
all: "All",
diamond: "Diamond",
gold: "Gold",
silver: "Silver",
bronze: "Bronze"
},
sponsorButton: "Sponsor Us",
footer: "© 2025 Legacy Lands Studio. All rights reserved.",
card: {
tier: {
diamond: "Diamond",
gold: "Gold",
silver: "Silver",
bronze: "Bronze"
}
}
},
contact: {
sponsor: {
title: "Sponsor",
description: "View our sponsors and support us",
button: "View Sponsors"
}
}
},
zh: {
title: "遗迹之地",
orgTitle: "专业团队",
orgDescription: "致力于打造优雅解决方案的专业软件开发团队。",
// 组织成员部分
roles: {
founder: "创始人",
mainplanner: "主策划",
planner: "策划",
maindeveloper: "首席开发者",
developer: "开发者",
mainbuilder: "主建筑师",
builder: "建筑师",
minecrafttechnician: "技术专员",
graphicdesigner: "平面设计师"
},
// 使命部分
missionTitle: "使命",
missionSubtitle: "构建未来,传承经典",
innovation: {
title: "创新",
subtitle: "突破边界",
description: "我们拥抱前沿技术和创新理念,致力于打造卓越的游戏体验。对探索的热忱驱动我们不断进化和改进。"
},
community: {
title: "社区",
subtitle: "共建共享",
description: "我们营造充满活力的社区环境,让创意蓬勃发展,让深厚友谊自然形成。每个声音都在塑造我们共同的数字世界。"
},
// 联系部分
contactTitle: "联系我们",
contactSubtitle: "有想法?一起来聊聊!",
// Hero section translations
hero: {
badge: "开源 & 商业",
title: "专业的 Minecraft 全能制作团队",
description: "集服务器开发、建筑设计、技术创新于一体的 Minecraft 专业团队。<br>专注于自主开发与运营大型沉浸式文明模拟服务器,同时深度参与开源生态建设,为 Minecraft 插件开发领域提供企业级技术框架与专业解决方案。",
viewProjects: "查看我们的项目",
github: "GitHub",
stats: {
teamMembers: "团队成员",
majorProjects: "主要项目",
codeCommits: "代码提交",
linesOfCode: "代码行数"
}
},
// Core business section
coreProjects: {
title: "我们的核心项目",
description: "两个旗舰项目展示我们在现代 Minecraft 制作方面的专业能力",
library: {
title: "遗迹之地库",
subtitle: "企业级 Minecraft 服务器插件开发框架",
description: "专为 Minecraft 服务器插件开发设计的企业级模块化框架,提供专业的开发工具和技术支持。",
tags: ["开源", "企业级", "插件开发", "模块化框架"],
button: "探索库"
},
server: {
title: "遗迹之地服务器",
subtitle: "Minecraft 文明模拟平台",
description: "一个专注于文明模拟、国家建设和协作游戏体验的沉浸式 Minecraft 服务器,为繁荣的社区服务。",
tags: ["商业", "多人游戏", "文明建设", "社区"],
button: "加入服务器"
}
},
qqgroup: {
title: "QQ 群",
description: "加入我们的社区",
button: "1022665227"
},
github: {
title: "GitHub",
description: "浏览我们的开源项目",
button: "查看项目"
},
founder: {
title: "创始人",
description: "联系创始人",
button: "发送邮件"
},
sponsor: {
title: "赞助",
description: "查看赞助者并支持我们",
button: "查看赞助者"
},
// 项目部分
library: {
title: "遗迹之地库",
description: "现代 Java 依赖库",
tags: ["框架", "开源", "现代 Java"],
button: "查看仓库"
},
server: {
title: "遗迹之地服务器",
description: "主要商业项目",
tags: ["Minecraft 服务器", "文明模拟"],
button: "加入 QQ 群"
},
// 成员技能
skills: {
funding: "融资",
planning: "策划",
operationandmaintenance: "运维",
java: "Java",
elixir: "Elixir",
frontend: "前端",
backend: "后端",
bukkit: "Bukkit",
devops: "DevOps",
builder: "建筑",
architectsofvariousstyles: "多风格建筑师",
minecrafttechnician: "技术专员",
graphicdesigner: "平面设计师"
},
// 使命卡片
heritage: {
title: "传承",
subtitle: "有意义的遗产",
description: "我们创造融合文化深度与吸引力玩法的持久体验。每个项目都承载着目标,为玩家和社区带来积极影响。"
},
experience: {
title: "体验",
subtitle: "精雕细琢",
description: "我们精心设计每一次交互,创造无缝、引人入胜的体验。从直观的界面到沉浸式的游戏玩法,品质体现在每个细节中。"
},
growth: {
title: "成长",
subtitle: "持续进化",
description: "我们相信迭代改进,从每次挑战中学习成长。对成长的承诺确保每个项目在质量和创新方面都超越前作。"
},
opensource: {
title: "开源",
subtitle: "协作创新",
description: "我们通过开源工具和框架为全球开发者社区做出贡献。知识共享加速创新,为每个人创造机会。"
},
sections: {
mission: "使命",
library: "遗迹之地库",
server: "遗迹之地服务器",
contact: "联系我们"
},
members: {
xiaoliang: {
name: "小梁",
role: "创始人"
},
feige: {
name: "飞鸽",
role: "主策划"
},
xiaochen: {
name: "小陈",
role: "策划"
},
linxi: {
name: "灵希 Psyche",
role: "首席开发者"
},
zuijiu: {
name: "醉酒",
role: "开发者"
},
neglectdream: {
name: "NeglectDream",
role: "开发者、技术专员"
},
autuo: {
name: "Autuo",
role: "技术专员"
},
cuixuan: {
name: "崔铉",
role: "平面设计师"
},
duya: {
name: "渡鸦",
role: "主建筑师"
},
heiyu: {
name: "黑鱼",
role: "建筑师"
}
},
sponsors: {
title: "赞助者名单",
subtitle: "感谢您的支持!",
search: "搜索赞助者...",
tiers: {
all: "全部",
diamond: "钻石",
gold: "黄金",
silver: "白银",
bronze: "青铜"
},
sponsorButton: "赞助我们",
footer: "© 2025 遗迹之地工作室。保留所有权利。",
card: {
tier: {
diamond: "钻石",
gold: "黄金",
silver: "白银",
bronze: "青铜"
}
}
}
}
};
// 在 translations 对象定义后添加
window.translations = translations;
let currentLang = 'en'; // 默认英文
let originalAttributes = null;
function setAllAttributes() {
if (!originalAttributes) {
originalAttributes = {
members: [],
skills: [],
missions: [],
contacts: []
};
// 保存成员卡片的原始属性
document.querySelectorAll('.member-card').forEach(card => {
const name = card.querySelector('h3').textContent;
const memberId = name.toLowerCase()
.replace(/\s*\([^)]*\)\s*/g, '') // 移除括号及其内容
.replace(/\s+/g, '') // 移除空格
.replace(/[^a-z]/g, ''); // 只保留小写字母
originalAttributes.members.push({
element: card,
name: name,
id: memberId
});
});
// 保存技能的原始属性
document.querySelectorAll('.member-skills span').forEach(skill => {
originalAttributes.skills.push({
element: skill,
text: skill.textContent
});
});
// 修改使命卡片的属性保存
document.querySelectorAll('.mission-card').forEach(card => {
const title = card.querySelector('h3').textContent;
const type = title.toLowerCase()
.replace(/[\s&]+/g, '')
.replace(/[^a-z]/g, '');
originalAttributes.missions.push({
element: card,
title: title,
type: type
});
});
// 修改联系卡片的属性保存
document.querySelectorAll('.contact-card').forEach(card => {
const title = card.querySelector('h3').textContent;
const type = title.toLowerCase()
.replace(/[\s&]+/g, '')
.replace(/[^a-z]/g, '');
originalAttributes.contacts.push({
element: card,
title: title,
type: type
});
});
}
// 使用原始属性来设置 data 属性
originalAttributes.members.forEach(item => {
item.element.setAttribute('data-member', item.id);
});
originalAttributes.skills.forEach(item => {
const skillKey = item.text.toLowerCase()
.replace(/[\s&]+/g, '')
.replace(/[^a-z]/g, '');
item.element.setAttribute('data-skill', skillKey);
});
// 修改使命卡片的属性设置
originalAttributes.missions.forEach(item => {
item.element.setAttribute('data-type', item.type);
});
// 修改联系卡片的属性设置
originalAttributes.contacts.forEach(item => {
item.element.setAttribute('data-type', item.type);
});
}
function updateButtonText() {
const langBtn = document.querySelector('.lang-btn');
if (langBtn) {
const langText = langBtn.querySelector('.lang-text');
if (langText) {
// 当前是英文时显示"中文",当前是中文时显示"English"
langText.textContent = currentLang === 'en' ? '中文' : 'English';
}
}
}
function toggleLanguage() {
currentLang = currentLang === 'en' ? 'zh' : 'en';
console.log('Language switched to:', currentLang);
// 将当前语言设置暴露给全局作用域,以便其他脚本访问
window.currentLang = currentLang;
// 先更新内容
updateContent();
// 然后重新设置属性
setAllAttributes();
// 最后更新按钮文本
updateButtonText();
}
function updateContent() {
const t = translations[currentLang];
// 安全地更新文本内容
function safeSetText(selector, text) {
const element = document.querySelector(selector);
if (element) {
element.textContent = text;
}
}
// 主标题和Logo
const mainTitle = document.querySelector('.main-title');
if (mainTitle) {
mainTitle.setAttribute('data-lang', currentLang);
if (currentLang === 'en') {
mainTitle.innerHTML = t.hero.title.replace(/Minecraft Complete Production Team/g, '<span class="highlight">Minecraft Complete Production Team</span>');
} else {
mainTitle.innerHTML = t.hero.title.replace(/Minecraft 全能制作团队/g, '<span class="highlight">Minecraft 全能制作团队</span>');
}
}
safeSetText('.logo', t.title);
// Hero section
safeSetText('.badge-text', t.hero.badge);
const heroDescription = document.querySelector('.hero-description');
if (heroDescription) {
heroDescription.innerHTML = t.hero.description;
}
// Hero buttons
const viewProjectsBtn = document.querySelector('.btn-primary');
if (viewProjectsBtn) {
viewProjectsBtn.textContent = t.hero.viewProjects;
}
const githubBtn = document.querySelector('.btn-secondary');
if (githubBtn) {
// 保留 SVG 图标,只更新文本
const svg = githubBtn.querySelector('svg');
githubBtn.innerHTML = '';
if (svg) githubBtn.appendChild(svg);
githubBtn.appendChild(document.createTextNode(t.hero.github));
}
// Hero stats
const stats = document.querySelectorAll('.stat');
if (stats.length >= 4) {
stats[0].querySelector('.stat-label').textContent = t.hero.stats.teamMembers;
stats[1].querySelector('.stat-label').textContent = t.hero.stats.majorProjects;
stats[2].querySelector('.stat-label').textContent = t.hero.stats.codeCommits;
stats[3].querySelector('.stat-label').textContent = t.hero.stats.linesOfCode;
}
// Core Projects section
safeSetText('.business-title', t.coreProjects.title);
safeSetText('.business-description', t.coreProjects.description);
// Core Projects cards
const businessCards = document.querySelectorAll('.business-card');
if (businessCards.length >= 2) {
// Library card
const libraryCard = businessCards[0];
libraryCard.querySelector('h3').textContent = t.coreProjects.library.title;
libraryCard.querySelector('p').textContent = t.coreProjects.library.subtitle;
libraryCard.querySelector('.card-description').textContent = t.coreProjects.library.description;
const libraryTags = libraryCard.querySelectorAll('.card-features span');
libraryTags.forEach((tag, i) => {
if (t.coreProjects.library.tags[i]) {
tag.textContent = t.coreProjects.library.tags[i];
}
});
const libraryLink = libraryCard.querySelector('.card-link');
if (libraryLink) {
const svg = libraryLink.querySelector('svg');
libraryLink.innerHTML = '';
if (svg) libraryLink.appendChild(svg);
libraryLink.appendChild(document.createTextNode(t.coreProjects.library.button));
}
// Server card
const serverCard = businessCards[1];
serverCard.querySelector('h3').textContent = t.coreProjects.server.title;
serverCard.querySelector('p').textContent = t.coreProjects.server.subtitle;
serverCard.querySelector('.card-description').textContent = t.coreProjects.server.description;
const serverTags = serverCard.querySelectorAll('.card-features span');
serverTags.forEach((tag, i) => {
if (t.coreProjects.server.tags[i]) {
tag.textContent = t.coreProjects.server.tags[i];
}
});
const serverLink = serverCard.querySelector('.card-link');
if (serverLink) {
const svg = serverLink.querySelector('svg');
serverLink.innerHTML = '';
if (svg) serverLink.appendChild(svg);
serverLink.appendChild(document.createTextNode(t.coreProjects.server.button));
}
}
// 组织部分
safeSetText('.org-title', t.orgTitle);
safeSetText('.org-description', t.orgDescription);
// 成员部分
document.querySelectorAll('.member-card').forEach(card => {
const memberId = card.getAttribute('data-member');
if (t.members[memberId]) {
card.querySelector('h3').textContent = t.members[memberId].name;
card.querySelector('p').textContent = t.members[memberId].role;
} else {
console.warn('Missing translation for member:', memberId);
}
});
// 成员技能
document.querySelectorAll('.member-skills span').forEach(skill => {
const skillKey = skill.getAttribute('data-skill');
if (t.skills[skillKey]) {
skill.textContent = t.skills[skillKey];
} else {
console.warn('Missing translation for skill:', skillKey);
}
});
// 项目部分
const codeSections = document.querySelectorAll('.code-section');
codeSections.forEach((section, index) => {
if (index === 0) {
// Library section
const descContent = section.querySelector('.description-content');
if (descContent) {
descContent.querySelector('h2').textContent = t.sections.library;
descContent.querySelector('p').textContent = t.library.description;
const tags = descContent.querySelectorAll('.feature-tags span');
tags.forEach((tag, i) => {
if (t.library.tags[i]) {
tag.textContent = t.library.tags[i];
}
});
const githubLink = descContent.querySelector('.github-link');
if (githubLink) {
// 清除现有内容
githubLink.innerHTML = '';
// 添加图标
const iconSpan = document.createElement('span');
iconSpan.className = 'github-icon';
iconSpan.innerHTML = `
<svg height="24" viewBox="0 0 16 16" width="24">
<path fill="#d4d4d4" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
</svg>
`;
// 添加文本
githubLink.appendChild(iconSpan);
githubLink.appendChild(document.createTextNode(t.library.button));
}
}
} else if (index === 1) {
// Server section
const descContent = section.querySelector('.description-content');
if (descContent) {
descContent.querySelector('h2').textContent = t.sections.server;
descContent.querySelector('p').textContent = t.server.description;
const tags = descContent.querySelectorAll('.feature-tags span');
tags.forEach((tag, i) => {
if (t.server.tags[i]) {
tag.textContent = t.server.tags[i];
}
});
const qqLink = descContent.querySelector('.qq-link');
if (qqLink) {
// 清除现有内容
qqLink.innerHTML = '';
// 添加图标
const iconSpan = document.createElement('span');
iconSpan.className = 'qq-icon';
iconSpan.innerHTML = `
<svg height="24" viewBox="0 0 24 24" width="24">
<path fill="#d4d4d4" d="M12.003 2c-2.265 0-6.29 1.364-6.29 7.325v1.195S3.55 14.96 3.55 17.474c0 .665.17 1.025.281 1.025.114 0 .902-.484 1.748-2.072 0 0-.18 2.197 1.904 3.967 0 0-1.77.495-1.77 1.182 0 .686 4.078.43 6.29.43 2.213 0 6.29.256 6.29-.43 0-.687-1.77-1.182-1.77-1.182 2.085-1.77 1.905-3.967 1.905-3.967.846 1.588 1.634 2.072 1.746 2.072.111 0 .283-.36.283-1.025 0-2.514-2.166-6.954-2.166-6.954V9.325C18.29 3.364 14.268 2 12.003 2z" />
</svg>
`;
// 添加文本
qqLink.appendChild(iconSpan);
qqLink.appendChild(document.createTextNode(t.server.button));
}
}
}
});
// 使命部分
const missionSection = document.querySelector('.mission-section');
if (missionSection) {
missionSection.querySelector('.mission-title').textContent = t.sections.mission;
missionSection.querySelector('.mission-subtitle').textContent = t.missionSubtitle;
// 使命卡片
const missionCards = missionSection.querySelectorAll('.mission-card');
missionCards.forEach(card => {
const type = card.getAttribute('data-type');
if (t[type]) {
card.querySelector('h3').textContent = t[type].title;
card.querySelector('h4').textContent = t[type].subtitle;
card.querySelector('p').textContent = t[type].description;
} else {
console.warn('Missing translation for mission card:', type);
}
});
}
// 联系部分
const contactSection = document.querySelector('.contact-section');
if (contactSection) {
contactSection.querySelector('.contact-title').textContent = t.sections.contact;
contactSection.querySelector('.contact-subtitle').textContent = t.contactSubtitle;
// 联系卡片
const contactCards = contactSection.querySelectorAll('.contact-card');
contactCards.forEach(card => {
const type = card.getAttribute('data-type');
if (t[type]) {
card.querySelector('h3').textContent = t[type].title;
card.querySelector('p').textContent = t[type].description;
const link = card.querySelector('.contact-link');
if (link) {
// 清除现有内容
link.innerHTML = '';
// 添加文本
link.appendChild(document.createTextNode(t[type].button));
// 添加箭头图标
const svg = document.createElement('svg');
svg.setAttribute('width', '24');
svg.setAttribute('height', '24');
svg.setAttribute('viewBox', '0 0 24 24');
svg.innerHTML = '<path fill="#d4d4d4" d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" />';
link.appendChild(svg);
}
} else {
console.warn('Missing translation for contact card:', type);
}
});
}
// 页脚
const footer = document.querySelector('.footer p');
if (footer) {
footer.textContent = currentLang === 'en'
? "© 2025 Legacy Lands Studio. All rights reserved."
: "© 2025 遗迹之地工作室。保留所有权利。";
}
// 更新赞助页面的内容
document.querySelectorAll('[data-i18n]').forEach(element => {
const key = element.getAttribute('data-i18n');
const translation = key.split('.').reduce((obj, key) => obj && obj[key], t);
if (translation) {
element.textContent = translation;
}
});
// 更新搜索框占位符
const searchInput = document.querySelector('[data-i18n-placeholder]');
if (searchInput) {
const key = searchInput.getAttribute('data-i18n-placeholder');
const translation = key.split('.').reduce((obj, key) => obj && obj[key], t);
if (translation) {
searchInput.placeholder = translation;
}
}
// 更新赞助者卡片的等级显示
document.querySelectorAll('.sponsor-tier').forEach(tier => {
const tierKey = tier.getAttribute('data-i18n');
if (tierKey) {
const translation = tierKey.split('.').reduce((obj, key) => obj && obj[key], t);
if (translation) {
tier.textContent = translation;
}
}
});
// 更新赞助者卡片的名称和描述
document.querySelectorAll('.sponsor-name').forEach(name => {
const nameEn = name.getAttribute('data-name-en');
const nameZh = name.getAttribute('data-name-zh');
name.textContent = currentLang === 'en' ? nameEn : nameZh;
});
document.querySelectorAll('.sponsor-description').forEach(desc => {
const descEn = desc.getAttribute('data-desc-en');
const descZh = desc.getAttribute('data-desc-zh');
desc.textContent = currentLang === 'en' ? descEn : descZh;
});
// 更新赞助者卡片(如果在 sponsors 页面)
if (window.sponsorsData && Array.isArray(window.sponsorsData)) {
resetAndReload(); // 重新加载赞助者卡片
}
}
// 页面加载完成后初始化语言
document.addEventListener('DOMContentLoaded', () => {
// 设置当前语言为全局变量
window.currentLang = currentLang;
// 首先设置所有属性
setAllAttributes();
// 绑定按钮事件
const langBtn = document.querySelector('.lang-btn');
if (langBtn) {
console.log('Language button found, binding event');
langBtn.removeEventListener('click', toggleLanguage);
langBtn.addEventListener('click', (e) => {
e.preventDefault();
console.log('Language button clicked');
toggleLanguage();
});
} else {
console.error('Language button not found');
}
// 初始化内容和按钮文本
updateContent();
updateButtonText();
// 初始化数字动画
initCountingAnimations();
// 处理hash路由
handleHashRouting();
});
// 处理hash路由(包括带斜杠的情况)
function handleHashRouting() {
function scrollToSection() {
const hash = window.location.hash;
if (hash) {
// 移除可能的斜杠和其他字符,只保留ID
const cleanHash = hash.replace(/[\/\?#]/g, '').split(/[\/\?]/)[0];
if (cleanHash) {
const element = document.getElementById(cleanHash);
if (element) {
element.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
}
}
}
// 页面加载时处理
scrollToSection();
// hash变化时处理
window.addEventListener('hashchange', scrollToSection);
}
// 数字计数动画函数
function animateNumber(element, target, duration = 2000) {
const start = 0;
const increment = target / (duration / 16); // 60 FPS
let current = start;
const timer = setInterval(() => {
current += increment;
if (current >= target) {
current = target;
clearInterval(timer);
}
// 格式化数字显示
if (target >= 1000) {
element.textContent = Math.floor(current).toLocaleString();
} else {
element.textContent = Math.floor(current);
}
}, 16);
}
// 初始化计数动画
function initCountingAnimations() {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const statNumbers = entry.target.querySelectorAll('.stat-number[data-target]');
statNumbers.forEach(numberEl => {
const target = parseInt(numberEl.getAttribute('data-target'));
// 延迟启动动画,让页面加载动画先完成
setTimeout(() => {
animateNumber(numberEl, target, 2500);
}, 1800);
});
observer.unobserve(entry.target);
}
});
}, {
threshold: 0.5
});
const heroStats = document.querySelector('.hero-stats');
if (heroStats) {
observer.observe(heroStats);
}
}