1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ <!-- 这里的标题将被i18n自动翻译 -->
7+ < title > Loading...</ title >
8+ < link rel ="stylesheet " href ="styles/main.css ">
9+ < link rel ="
stylesheet "
href ="
https://cdn.jsdelivr.net/npm/[email protected] /fonts/remixicon.css "
> 10+
11+ <!-- 先加载语言资源文件 -->
12+ < script src ="js/i18n/zh-CN.js "> </ script >
13+ < script src ="js/i18n/en-US.js "> </ script >
14+
15+ <!-- 然后加载i18n核心库 -->
16+ < script src ="js/i18n/i18n-core.js "> </ script >
17+
18+ < style >
19+ .demo-container {
20+ max-width : 800px ;
21+ margin : 2rem auto;
22+ padding : 1rem ;
23+ border : 1px solid # e5e7eb ;
24+ border-radius : 8px ;
25+ box-shadow : 0 2px 4px rgba (0 , 0 , 0 , 0.05 );
26+ }
27+
28+ .demo-section {
29+ margin-bottom : 2rem ;
30+ padding : 1rem ;
31+ border-bottom : 1px solid # e5e7eb ;
32+ }
33+
34+ .example-box {
35+ background-color : # f9fafb ;
36+ padding : 1rem ;
37+ border-radius : 4px ;
38+ margin-top : 1rem ;
39+ }
40+
41+ pre {
42+ background-color : # f1f5f9 ;
43+ padding : 1rem ;
44+ border-radius : 4px ;
45+ overflow-x : auto;
46+ }
47+
48+ code {
49+ font-family : 'Courier New' , monospace;
50+ font-size : 0.9rem ;
51+ }
52+ </ style >
53+ </ head >
54+ < body >
55+ <!-- 顶部导航 -->
56+ < nav class ="header ">
57+ < div class ="nav-container ">
58+ < div class ="nav-left ">
59+ < a href ="index.html " class ="logo ">
60+ < img src ="https://cdn.jsdelivr.net/gh/JSREI/js-debugger-bypass-goat/assets/logo.png " alt ="Logo ">
61+ < span data-i18n ="title "> JavaScript调试绕过靶场测试平台</ span >
62+ </ a >
63+ </ div >
64+
65+ < div class ="nav-right ">
66+ < ul >
67+ < li > < a href ="index.html "> < i class ="ri-home-line "> </ i > < span data-i18n ="nav.home "> 首页</ span > </ a > </ li >
68+ < li > < a href ="cases/index.html "> < i class ="ri-flask-line "> </ i > < span data-i18n ="nav.testCases "> 测试用例</ span > </ a > </ li >
69+ < li class ="lang-dropdown ">
70+ < button class ="lang-selector ">
71+ < i class ="ri-global-line "> </ i >
72+ < span class ="current-lang "> 中文</ span >
73+ </ button >
74+ < div class ="lang-dropdown-content ">
75+ < div id ="lang-zh " class ="lang-option " data-lang ="zh-CN "> 中文</ div >
76+ < div id ="lang-en " class ="lang-option " data-lang ="en-US "> English</ div >
77+ </ div >
78+ </ li >
79+ </ ul >
80+ </ div >
81+ </ div >
82+ </ nav >
83+
84+ < div class ="demo-container ">
85+ < h1 data-i18n ="demoPage.title "> i18n 系统演示</ h1 >
86+ < p data-i18n ="demoPage.description "> 本页面展示了新版声明式i18n系统的使用方法</ p >
87+
88+ < div class ="demo-section ">
89+ < h2 data-i18n ="demoPage.sections.basic.title "> 基本文本翻译</ h2 >
90+ < p data-i18n ="demoPage.sections.basic.description "> 使用 data-i18n 属性来翻译文本内容</ p >
91+
92+ < div class ="example-box ">
93+ < h4 > 例子:</ h4 >
94+ < p data-i18n ="testCase.eval.title "> eval 执行测试</ p >
95+ < pre > < code > <p data-i18n="testCase.eval.title">eval 执行测试</p></ code > </ pre >
96+ </ div >
97+ </ div >
98+
99+ < div class ="demo-section ">
100+ < h2 data-i18n ="demoPage.sections.html.title "> HTML内容翻译</ h2 >
101+ < p data-i18n ="demoPage.sections.html.description "> 使用 data-i18n-html 属性来翻译HTML内容</ p >
102+
103+ < div class ="example-box ">
104+ < h4 > 例子:</ h4 >
105+ < p data-i18n-html ="demoPage.sections.html.example "> 这是包含< code > HTML标签</ code > 的内容</ p >
106+ < pre > < code > <p data-i18n-html="demoPage.sections.html.example">这是包含<code>HTML标签</code>的内容</p></ code > </ pre >
107+ </ div >
108+ </ div >
109+
110+ < div class ="demo-section ">
111+ < h2 data-i18n ="demoPage.sections.attr.title "> 属性翻译</ h2 >
112+ < p data-i18n ="demoPage.sections.attr.description "> 使用 data-i18n-attr 属性来翻译元素的其他属性</ p >
113+
114+ < div class ="example-box ">
115+ < h4 > 例子:</ h4 >
116+ < input type ="text " data-i18n-attr ="placeholder:demoPage.sections.attr.placeholder ">
117+ < pre > < code > <input type="text" data-i18n-attr="placeholder:demoPage.sections.attr.placeholder"></ code > </ pre >
118+ </ div >
119+ </ div >
120+
121+ < div class ="demo-section ">
122+ < h2 data-i18n ="demoPage.sections.params.title "> 参数插值</ h2 >
123+ < p data-i18n ="demoPage.sections.params.description "> 通过 data-i18n-params 属性传递插值参数</ p >
124+
125+ < div class ="example-box ">
126+ < h4 > 例子:</ h4 >
127+ < p
128+ data-i18n ="testCase.success.detail "
129+ data-i18n-params ='{"time": "47"} '> 执行时间: 47ms</ p >
130+ < pre > < code > <p data-i18n="testCase.success.detail" data-i18n-params='{"time": "47"}'>执行时间: 47ms</p></ code > </ pre >
131+ </ div >
132+ </ div >
133+
134+ < div class ="demo-section ">
135+ < h2 data-i18n ="demoPage.sections.dynamic.title "> 动态内容</ h2 >
136+ < p data-i18n ="demoPage.sections.dynamic.description "> 动态添加的元素也会自动翻译</ p >
137+
138+ < div class ="example-box ">
139+ < h4 > 例子:</ h4 >
140+ < button onclick ="addDynamicElement() "> 添加新元素</ button >
141+ < div id ="dynamicContainer "> </ div >
142+
143+ < script >
144+ function addDynamicElement ( ) {
145+ const container = document . getElementById ( 'dynamicContainer' ) ;
146+ const paragraph = document . createElement ( 'p' ) ;
147+ paragraph . setAttribute ( 'data-i18n' , 'demoPage.sections.dynamic.newElement' ) ;
148+ // 默认文本 (在翻译被应用前可能会短暂显示)
149+ paragraph . textContent = '这是动态添加的元素' ;
150+ container . appendChild ( paragraph ) ;
151+ }
152+ </ script >
153+
154+ < pre > < code > // JavaScript 代码
155+ function addDynamicElement() {
156+ const container = document.getElementById('dynamicContainer');
157+ const paragraph = document.createElement('p');
158+ paragraph.setAttribute('data-i18n', 'demoPage.sections.dynamic.newElement');
159+ paragraph.textContent = '这是动态添加的元素';
160+ container.appendChild(paragraph);
161+ }</ code > </ pre >
162+ </ div >
163+ </ div >
164+ </ div >
165+
166+ <!-- 页脚 -->
167+ < footer class ="footer ">
168+ < div class ="footer-container ">
169+ < div class ="footer-links ">
170+ < a href ="https://github.com/JSREI/js-debugger-bypass-goat " target ="_blank ">
171+ < i class ="ri-github-fill "> </ i > GitHub
172+ </ a >
173+ < a href ="https://github.com/JSREI/js-debugger-bypass-goat/issues " target ="_blank ">
174+ < i class ="ri-error-warning-line "> </ i > < span data-i18n ="footer.feedback "> 问题反馈</ span >
175+ </ a >
176+ </ div >
177+ < p class ="copyright " data-i18n ="footer.rights "> © 2024 JSREI (JavaScript Reverse Engineering Infrastructure). All rights reserved.</ p >
178+ </ div >
179+ </ footer >
180+
181+ <!-- 添加翻译资源,用于演示 -->
182+ < script >
183+ // 添加演示页面的翻译资源
184+ zhCN . demoPage = {
185+ title : 'i18n 系统演示' ,
186+ description : '本页面展示了新版声明式i18n系统的使用方法' ,
187+ sections : {
188+ basic : {
189+ title : '基本文本翻译' ,
190+ description : '使用 data-i18n 属性来翻译文本内容'
191+ } ,
192+ html : {
193+ title : 'HTML内容翻译' ,
194+ description : '使用 data-i18n-html 属性来翻译HTML内容' ,
195+ example : '这是包含<code>HTML标签</code>的内容'
196+ } ,
197+ attr : {
198+ title : '属性翻译' ,
199+ description : '使用 data-i18n-attr 属性来翻译元素的其他属性' ,
200+ placeholder : '请输入内容...'
201+ } ,
202+ params : {
203+ title : '参数插值' ,
204+ description : '通过 data-i18n-params 属性传递插值参数'
205+ } ,
206+ dynamic : {
207+ title : '动态内容' ,
208+ description : '动态添加的元素也会自动翻译' ,
209+ newElement : '这是动态添加的元素(中文)'
210+ }
211+ }
212+ } ;
213+
214+ enUS . demoPage = {
215+ title : 'i18n System Demo' ,
216+ description : 'This page demonstrates how to use the new declarative i18n system' ,
217+ sections : {
218+ basic : {
219+ title : 'Basic Text Translation' ,
220+ description : 'Use the data-i18n attribute to translate text content'
221+ } ,
222+ html : {
223+ title : 'HTML Content Translation' ,
224+ description : 'Use data-i18n-html attribute to translate HTML content' ,
225+ example : 'This content contains <code>HTML tags</code>'
226+ } ,
227+ attr : {
228+ title : 'Attribute Translation' ,
229+ description : 'Use data-i18n-attr attribute to translate other element attributes' ,
230+ placeholder : 'Enter content...'
231+ } ,
232+ params : {
233+ title : 'Parameter Interpolation' ,
234+ description : 'Pass interpolation parameters using data-i18n-params attribute'
235+ } ,
236+ dynamic : {
237+ title : 'Dynamic Content' ,
238+ description : 'Dynamically added elements are also translated automatically' ,
239+ newElement : 'This is a dynamically added element (English)'
240+ }
241+ }
242+ } ;
243+ </ script >
244+ </ body >
245+ </ html >
0 commit comments