prism-code-workspace 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prism_code_workspace-1.0.0.dist-info/METADATA +272 -0
- prism_code_workspace-1.0.0.dist-info/RECORD +30 -0
- prism_code_workspace-1.0.0.dist-info/WHEEL +4 -0
- prism_code_workspace-1.0.0.dist-info/entry_points.txt +3 -0
- prism_code_workspace-1.0.0.dist-info/licenses/LICENSE +21 -0
- python_app/__init__.py +3 -0
- python_app/ai.py +225 -0
- python_app/analysis.py +953 -0
- python_app/compare.py +685 -0
- python_app/compare_engine.py +284 -0
- python_app/compiled_analysis.py +727 -0
- python_app/desktop.py +181 -0
- python_app/function_pov/__init__.py +16 -0
- python_app/function_pov/analyzer.py +464 -0
- python_app/function_pov/graph.py +50 -0
- python_app/function_pov/models.py +53 -0
- python_app/function_pov/pov/__init__.py +17 -0
- python_app/function_pov/pov/engine.py +1630 -0
- python_app/function_pov/pov/exercises.py +1263 -0
- python_app/function_pov_ui.py +1749 -0
- python_app/i18n.py +570 -0
- python_app/installer.nsi +70 -0
- python_app/installer_runtime.nsi +70 -0
- python_app/js_analysis.py +709 -0
- python_app/launch.py +6 -0
- python_app/launch_native.py +14 -0
- python_app/metrics_advisor.py +79 -0
- python_app/native_app.py +1709 -0
- python_app/requirements.txt +7 -0
- python_app/server.py +453 -0
python_app/i18n.py
ADDED
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
"""Interface strings for Prism.
|
|
2
|
+
|
|
3
|
+
English is the source language: the string passed to :func:`tr` is both the key
|
|
4
|
+
and the fallback, so a missing translation degrades to readable English rather
|
|
5
|
+
than to ``compare.title``-style keys. Adding a language means adding one dict.
|
|
6
|
+
|
|
7
|
+
The analysis text Prism generates (guides, trace notes) stays in English; this
|
|
8
|
+
module only covers the interface around it.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import re
|
|
14
|
+
from typing import Dict, Iterable, List
|
|
15
|
+
|
|
16
|
+
LANGUAGES = [
|
|
17
|
+
("en", "English"),
|
|
18
|
+
("zh", "简体中文"),
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
_TABLES: Dict[str, Dict[str, str]] = {
|
|
22
|
+
"en": {},
|
|
23
|
+
"zh": {
|
|
24
|
+
"Simulation incomplete": "模拟未完成",
|
|
25
|
+
"Completed · no output": "运行完成 · 无输出",
|
|
26
|
+
"Partial output": "部分输出",
|
|
27
|
+
"Return": "返回值",
|
|
28
|
+
# -- window chrome -------------------------------------------------
|
|
29
|
+
"Prism — code analysis workspace": "Prism — 代码分析工作台",
|
|
30
|
+
"CODE WORKSPACE": "代码工作台",
|
|
31
|
+
"Connect AI": "连接 AI",
|
|
32
|
+
"Local · six languages": "本地 · 六种语言",
|
|
33
|
+
"Local · Python": "本地 · Python",
|
|
34
|
+
"Local · Python / JavaScript / TypeScript / Java / C++ / C":
|
|
35
|
+
"本地 · Python / JavaScript / TypeScript / Java / C++ / C",
|
|
36
|
+
"Compare · structural diff between two versions": "对比 · 两个版本的结构差异",
|
|
37
|
+
"UI language": "界面语言",
|
|
38
|
+
# -- menus ---------------------------------------------------------
|
|
39
|
+
"&File": "文件(&F)",
|
|
40
|
+
"&View": "视图(&V)",
|
|
41
|
+
"&Tools": "工具(&T)",
|
|
42
|
+
"&Help": "帮助(&H)",
|
|
43
|
+
"New analysis": "新建分析",
|
|
44
|
+
"Open Python file…": "打开源文件…",
|
|
45
|
+
"Save guide…": "保存讲解…",
|
|
46
|
+
"Quit": "退出",
|
|
47
|
+
"Toggle full screen": "切换全屏",
|
|
48
|
+
"Compare two versions…": "对比两个版本…",
|
|
49
|
+
"Connect AI…": "连接 AI…",
|
|
50
|
+
"Enhance current guide…": "增强当前讲解…",
|
|
51
|
+
"About Prism": "关于 Prism",
|
|
52
|
+
# -- welcome -------------------------------------------------------
|
|
53
|
+
"LOCAL CODE WORKSPACE": "本地代码工作台",
|
|
54
|
+
"Code, made clear.": "让代码看得明白。",
|
|
55
|
+
"Write or import code. Prism explains the flow, structure, execution, "
|
|
56
|
+
"and data without leaving this window.":
|
|
57
|
+
"写上一段代码,或者导入一个文件。Prism 不离开这个窗口就能讲清楚它的"
|
|
58
|
+
"流程、结构、执行过程和数据。",
|
|
59
|
+
"Start an analysis": "开始一次分析",
|
|
60
|
+
"The document starts blank. Open the editor, import a source file, or try a case.":
|
|
61
|
+
"文档从空白开始。打开编辑器、导入源文件,或者试试示例。",
|
|
62
|
+
"Language": "语言",
|
|
63
|
+
"Open editor": "打开编辑器",
|
|
64
|
+
"Import file": "导入文件",
|
|
65
|
+
"Try a case": "试试示例",
|
|
66
|
+
"Compare versions": "对比版本",
|
|
67
|
+
"FLOWCHART Trace decisions and loops\n"
|
|
68
|
+
"SYNTAX TREE Inspect the AST structure\n"
|
|
69
|
+
"LIVE TRACE Step through the safe run\n"
|
|
70
|
+
"DATA FLOW Follow values to their use\n"
|
|
71
|
+
"GUIDE Read the explanation beside the code":
|
|
72
|
+
"流程图 跟踪分支与循环\n"
|
|
73
|
+
"语法树 查看 AST 结构\n"
|
|
74
|
+
"实时跟踪 逐步走一遍安全执行\n"
|
|
75
|
+
"数据流 跟随变量到使用处\n"
|
|
76
|
+
"讲解 在代码旁边读说明",
|
|
77
|
+
"Local only · Python · JavaScript · TypeScript · Java · C++ · C":
|
|
78
|
+
"仅本地运行 · Python · JavaScript · TypeScript · Java · C++ · C",
|
|
79
|
+
# -- editor --------------------------------------------------------
|
|
80
|
+
"← Welcome": "← 首页",
|
|
81
|
+
"Import": "导入",
|
|
82
|
+
"Clear": "清空",
|
|
83
|
+
"Write Python code here…": "在这里写代码…",
|
|
84
|
+
"Blank document": "空白文档",
|
|
85
|
+
"Visualize & explain": "可视化并讲解",
|
|
86
|
+
"Import source file": "导入源文件",
|
|
87
|
+
"Code files": "代码文件",
|
|
88
|
+
"Could not read file": "无法读取文件",
|
|
89
|
+
"File too large": "文件太大",
|
|
90
|
+
"Source files must stay under 60,000 characters.": "源文件不能超过 60,000 个字符。",
|
|
91
|
+
# -- results -------------------------------------------------------
|
|
92
|
+
"Enhance guide": "增强讲解",
|
|
93
|
+
"Edit code": "编辑代码",
|
|
94
|
+
"Save guide": "保存讲解",
|
|
95
|
+
"Flowchart": "流程图",
|
|
96
|
+
"Syntax Tree": "语法树",
|
|
97
|
+
"Live Trace": "实时跟踪",
|
|
98
|
+
"Data Flow": "数据流",
|
|
99
|
+
"Guide": "讲解",
|
|
100
|
+
# -- Function POV -----------------------------------------------
|
|
101
|
+
"Function POV": "函数 POV",
|
|
102
|
+
"Function POV currently supports Python only.":
|
|
103
|
+
"函数 POV 目前只支持 Python。",
|
|
104
|
+
"Function POV is available for this Python analysis.":
|
|
105
|
+
"此 Python 分析可以使用函数 POV。",
|
|
106
|
+
"Open Function POV to see language support.":
|
|
107
|
+
"打开函数 POV 查看语言支持说明。",
|
|
108
|
+
"Function POV · safe Python simulation": "函数 POV · 安全 Python 模拟",
|
|
109
|
+
"← Back to analysis": "← 返回分析结果",
|
|
110
|
+
"FUNCTION POV · SAFE PRACTICE": "函数 POV · 安全练习",
|
|
111
|
+
"BE THE CODE · SAFE PRACTICE": "成为代码 · 安全练习",
|
|
112
|
+
"Be the Code": "成为代码",
|
|
113
|
+
"Be the Function": "成为函数",
|
|
114
|
+
"A FUNCTION IS A JOURNEY": "走进函数的执行旅程",
|
|
115
|
+
"A PROGRAM IS A JOURNEY": "走进程序的执行旅程",
|
|
116
|
+
"Follow top-level statements, changing values, decisions, loops, and output. "
|
|
117
|
+
"Prism uses a bounded simulation; it never runs your Python code.":
|
|
118
|
+
"跟随顶层语句、变量变化、判断、循环和输出。Prism 使用有边界的模拟,"
|
|
119
|
+
"绝不会运行你的 Python 代码。",
|
|
120
|
+
"Choose a function, follow its values, and practise each decision. "
|
|
121
|
+
"Prism uses a bounded simulation; it never runs your Python code.":
|
|
122
|
+
"选择一个函数,跟随变量的变化并练习每个判断。Prism 使用有边界的模拟,"
|
|
123
|
+
"绝不会运行你的 Python 代码。",
|
|
124
|
+
"CHOOSE A FUNCTION": "选择函数",
|
|
125
|
+
"WHOLE PROGRAM": "整个程序",
|
|
126
|
+
"Program": "程序",
|
|
127
|
+
"Follow executable top-level statements from start to finish.":
|
|
128
|
+
"从头到尾跟随可执行的顶层语句。",
|
|
129
|
+
"Only a bounded Python subset is simulated. Unsupported statements are explained before play.":
|
|
130
|
+
"这里只模拟有边界的 Python 子集。不支持的语句会在开始前说明。",
|
|
131
|
+
"Trace whole program": "跟踪整个程序",
|
|
132
|
+
"This program is outside the safe simulation subset: {error}":
|
|
133
|
+
"此程序使用了安全模拟范围之外的语法:{error}",
|
|
134
|
+
"Ready for Be the Code. The simulator follows bounded steps and never executes your Python code.":
|
|
135
|
+
"可以开始“成为代码”。模拟器会在有限步骤内跟踪程序,绝不会执行你的 Python 代码。",
|
|
136
|
+
"No executable statements were found.": "没有找到可执行语句。",
|
|
137
|
+
"Select a function": "选择一个函数",
|
|
138
|
+
"Function details and arguments will appear here.": "函数信息和参数会显示在这里。",
|
|
139
|
+
"ARGUMENTS · ENTER JSON VALUES": "参数 · 输入 JSON 值",
|
|
140
|
+
"Blank optional arguments use their defaults. Only a safe subset of Python is simulated.":
|
|
141
|
+
"可选参数留空时使用默认值。这里只模拟 Python 的安全子集。",
|
|
142
|
+
"Enter function space": "进入函数空间",
|
|
143
|
+
"Select a supported function to begin.": "选择一个受支持的函数开始练习。",
|
|
144
|
+
"YOUR FUNCTION · CURRENT LINE HIGHLIGHTED": "当前函数 · 高亮显示正在执行的行",
|
|
145
|
+
"CALL STACK": "调用栈",
|
|
146
|
+
"LOCAL VARIABLES": "局部变量",
|
|
147
|
+
"ANSWER HISTORY": "答题记录",
|
|
148
|
+
"← Previous": "← 上一步",
|
|
149
|
+
"↻ Restart": "↻ 重新开始",
|
|
150
|
+
"Hint": "提示",
|
|
151
|
+
"Show answer": "显示答案",
|
|
152
|
+
"Check answer": "检查答案",
|
|
153
|
+
"↻ Replay function": "↻ 重玩函数",
|
|
154
|
+
"↻ Replay program": "↻ 重玩程序",
|
|
155
|
+
"PROGRAM STEP {current} OF {total}": "程序第 {current}/{total} 步",
|
|
156
|
+
"WHOLE PROGRAM · {file}": "整个程序 · {file}",
|
|
157
|
+
"PROGRAM CALL STACK": "程序调用栈",
|
|
158
|
+
"PROGRAM VARIABLES": "程序变量",
|
|
159
|
+
"Predict the first meaningful operation.": "预测首先出现的重要操作。",
|
|
160
|
+
"The program finished. Review its final output.": "程序已结束。查看最终输出。",
|
|
161
|
+
"State update: {expression}": "状态更新:{expression}",
|
|
162
|
+
"Does the loop condition evaluate to True or False?": "循环条件的结果是 True 还是 False?",
|
|
163
|
+
"Will the for loop execute another pass?": "for 循环还会再执行一轮吗?",
|
|
164
|
+
"Check whether any values remain in the iterable.":
|
|
165
|
+
"请检查可迭代对象中是否还有剩余值。",
|
|
166
|
+
"What value is assigned to {target} in the next loop pass?":
|
|
167
|
+
"下一轮循环会给 {target} 赋什么值?",
|
|
168
|
+
"Loop state: {expression}": "循环状态:{expression}",
|
|
169
|
+
"What text does this print call output?": "这次 print 会输出什么文本?",
|
|
170
|
+
"Choose whether the loop continues or stops.": "选择循环继续还是停止。",
|
|
171
|
+
"Enter the next loop value as a JSON value.": "以 JSON 值输入下一轮循环值。",
|
|
172
|
+
"Choose the first meaningful operation in the program.":
|
|
173
|
+
"选择程序中首先出现的重要操作。",
|
|
174
|
+
"Enter the printed text as a JSON string.": "以 JSON 字符串输入输出文本。",
|
|
175
|
+
"Branch decision": "分支判断",
|
|
176
|
+
"Loop iteration": "循环迭代",
|
|
177
|
+
"Variable update": "变量更新",
|
|
178
|
+
"Function call": "函数调用",
|
|
179
|
+
"Output": "输出",
|
|
180
|
+
"New Values": "更换数值",
|
|
181
|
+
"Similar Logic": "相似逻辑",
|
|
182
|
+
"condition": "条件判断",
|
|
183
|
+
"branch": "分支",
|
|
184
|
+
"loop": "循环",
|
|
185
|
+
"arithmetic": "算术运算",
|
|
186
|
+
"return": "返回值",
|
|
187
|
+
"function parameters": "函数参数",
|
|
188
|
+
"related Python concepts": "相关 Python 概念",
|
|
189
|
+
"Practice Similar Questions": "练习类似题目",
|
|
190
|
+
"Choose a practice level. The original source stays unchanged, and each new exercise is checked by Prism's safe simulator.":
|
|
191
|
+
"选择练习级别。原始代码保持不变,每道新题都会由 Prism 安全模拟器验证。",
|
|
192
|
+
"Original exercise": "原始练习",
|
|
193
|
+
"New exercise · compare before starting": "新练习 · 开始前可与原题对照",
|
|
194
|
+
"Original arguments: {values}": "原始参数:{values}",
|
|
195
|
+
"New arguments: {values}": "新参数:{values}",
|
|
196
|
+
"← Back to completion": "← 返回完成页",
|
|
197
|
+
"Start this exercise": "开始此练习",
|
|
198
|
+
"Choose a level to generate a verified practice exercise.":
|
|
199
|
+
"选择一个级别,生成经过验证的练习题。",
|
|
200
|
+
"Generated {level} exercise. Concepts: {concepts}. The candidate passed safe simulation.":
|
|
201
|
+
"已生成“{level}”练习。涉及概念:{concepts}。该题已通过安全模拟验证。",
|
|
202
|
+
"Logic change: {explanation}": "逻辑变化:{explanation}",
|
|
203
|
+
"The comparison rule changed; practise evaluating the condition and choosing a branch.":
|
|
204
|
+
"比较规则发生了变化;练习判断条件并选择对应分支。",
|
|
205
|
+
"The arithmetic or variable-update rule changed; practise tracing each calculation.":
|
|
206
|
+
"算术运算或变量更新规则发生了变化;练习逐步跟踪计算。",
|
|
207
|
+
"The branch or loop structure changed; practise tracing the new execution path.":
|
|
208
|
+
"分支或循环结构发生了变化;练习跟踪新的执行路径。",
|
|
209
|
+
"The expression structure changed; practise tracing how it affects the result.":
|
|
210
|
+
"表达式结构发生了变化;练习跟踪它如何影响结果。",
|
|
211
|
+
"Complete an original practice first to create a similar exercise.":
|
|
212
|
+
"请先完成一道原始练习,再生成类似题目。",
|
|
213
|
+
"This practice mode is not supported.": "此练习模式不受支持。",
|
|
214
|
+
"This exercise level is not supported.": "此练习级别不受支持。",
|
|
215
|
+
"No safe, unused New Values exercise is available for this code.":
|
|
216
|
+
"此代码没有可安全生成且未练习过的“更换数值”题目。",
|
|
217
|
+
"This code does not match a supported Similar Logic pattern.":
|
|
218
|
+
"此代码不符合当前支持的“相似逻辑”题型。",
|
|
219
|
+
"No unused Similar Logic exercise passed safe simulation.":
|
|
220
|
+
"没有未练习过且通过安全模拟的“相似逻辑”题目。",
|
|
221
|
+
"Exercise search reached its safe candidate limit without finding a new variant.":
|
|
222
|
+
"在安全候选数量上限内未找到新的练习题。",
|
|
223
|
+
"Practice level: {level} · Concepts: {concepts}":
|
|
224
|
+
"练习级别:{level} · 涉及概念:{concepts}",
|
|
225
|
+
"True": "True",
|
|
226
|
+
"False": "False",
|
|
227
|
+
"State updated: {state}": "状态已更新:{state}",
|
|
228
|
+
"Loop pass state: {state}": "本轮循环状态:{state}",
|
|
229
|
+
"Program output: {output}": "程序输出:{output}",
|
|
230
|
+
"No output was produced.": "程序没有产生输出。",
|
|
231
|
+
"Review the source before the first operation.": "先查看代码,再开始第一个操作。",
|
|
232
|
+
"Calculate the result using the values shown.": "根据显示的变量值计算结果。",
|
|
233
|
+
"Choose the branch that matches this condition.": "选择符合此条件的分支。",
|
|
234
|
+
"Choose the function called at this line.": "选择这一行调用的函数。",
|
|
235
|
+
"Predict the text printed here.": "预测这里输出的文本。",
|
|
236
|
+
"Not quite. Substitute the current values, then apply the operator. "
|
|
237
|
+
"For an update, start with the variable's previous value.":
|
|
238
|
+
"还不对。请代入当前变量值并应用运算符;更新变量时,先使用它之前的值。",
|
|
239
|
+
"Not quite. Evaluate the comparison with the values shown, then follow "
|
|
240
|
+
"the matching True or False branch.":
|
|
241
|
+
"还不对。请用显示的值计算比较结果,再进入对应的 True 或 False 分支。",
|
|
242
|
+
"Not quite. Read the iterable from left to right; each loop pass uses "
|
|
243
|
+
"the next value, not the previous one.":
|
|
244
|
+
"还不对。请从左到右查看可迭代对象;每轮循环使用下一个值,而不是上一个值。",
|
|
245
|
+
"Not quite. Re-evaluate the loop condition with the updated variables "
|
|
246
|
+
"to decide whether another iteration occurs.":
|
|
247
|
+
"还不对。请用更新后的变量重新计算循环条件,判断是否还要迭代。",
|
|
248
|
+
"Not quite. Check whether another value remains in the iterable.":
|
|
249
|
+
"还不对。请检查可迭代对象中是否还有下一个值。",
|
|
250
|
+
"Not quite. Evaluate each print argument in order, convert the values "
|
|
251
|
+
"to text, and join them with spaces.":
|
|
252
|
+
"还不对。请按顺序计算 print 的各个参数,将结果转为文本后用空格连接。",
|
|
253
|
+
"Not quite. Evaluate the return expression using this function's local "
|
|
254
|
+
"variables; that value is passed back to the caller.":
|
|
255
|
+
"还不对。请用此函数的局部变量计算 return 表达式;该值会传回调用者。",
|
|
256
|
+
"Not quite. Match the called function name, then trace how its arguments "
|
|
257
|
+
"become local parameter values.":
|
|
258
|
+
"还不对。请确认被调用的函数名称,再跟踪实参如何成为函数的局部参数值。",
|
|
259
|
+
"Not quite. Look past simple assignments for the first decision, loop, update, call, or output.":
|
|
260
|
+
"还不对。略过简单赋值,寻找第一个判断、循环、更新、调用或输出。",
|
|
261
|
+
"Substitute the current values into the while condition.":
|
|
262
|
+
"将当前变量值代入 while 条件。",
|
|
263
|
+
"Follow the iterable from left to right and find the next value.":
|
|
264
|
+
"从左到右查看可迭代对象,找出下一个值。",
|
|
265
|
+
"Evaluate each print argument, convert it to text, then join them with spaces.":
|
|
266
|
+
"分别计算 print 的参数,将其转换为文本后用空格连接。",
|
|
267
|
+
"Skip simple assignments and find the first decision, loop, update, call, or output.":
|
|
268
|
+
"略过简单赋值,寻找第一个判断、循环、更新、调用或输出。",
|
|
269
|
+
"Mode: Be the Code\nChallenges: {total} · Solved by you: {solved} · "
|
|
270
|
+
"Answers revealed: {revealed} · Attempts: {attempts}{practice}\n"
|
|
271
|
+
"Final output:\n{output}\nFinal variables: {variables}":
|
|
272
|
+
"模式:成为代码\n挑战:{total} · 自行答对:{solved} · 查看答案:{revealed} · "
|
|
273
|
+
"尝试次数:{attempts}{practice}\n最终输出:\n{output}\n最终变量:{variables}",
|
|
274
|
+
"Output shortened for display.": "输出过长,摘要中已截短。",
|
|
275
|
+
"MISSION COMPLETE": "任务完成",
|
|
276
|
+
"Stage clear!": "关卡完成!",
|
|
277
|
+
"Python syntax could not be analysed: {error}": "无法分析 Python 语法:{error}",
|
|
278
|
+
"No top-level synchronous functions were found. "
|
|
279
|
+
"Function POV needs a regular def function to begin.":
|
|
280
|
+
"没有找到顶层同步函数。函数 POV 需要普通的 def 函数才能开始。",
|
|
281
|
+
"This is a simplified, bounded simulation. Unsupported syntax is explained before play.":
|
|
282
|
+
"这是简化且有边界的模拟。不支持的语法会在开始前说明。",
|
|
283
|
+
"Other structures may be outside the supported subset: {details}":
|
|
284
|
+
"其他结构可能不在支持范围内:{details}",
|
|
285
|
+
"No docstring is available for this function.": "此函数没有文档字符串。",
|
|
286
|
+
"Calls: {calls} · Called by: {callers}": "调用:{calls} · 被调用:{callers}",
|
|
287
|
+
"none": "无",
|
|
288
|
+
"Leave blank to use default": "留空以使用默认值",
|
|
289
|
+
"Required JSON value": "必填的 JSON 值",
|
|
290
|
+
"This function has no parameters.": "此函数没有参数。",
|
|
291
|
+
"This function uses advanced parameter syntax. "
|
|
292
|
+
"Phase 1 supports simple positional parameters only.":
|
|
293
|
+
"此函数使用了高级参数语法。第一阶段仅支持简单的位置参数。",
|
|
294
|
+
"Blank optional arguments use their defaults. "
|
|
295
|
+
"The simulation never executes your code.":
|
|
296
|
+
"可选参数留空时使用默认值。模拟过程绝不会执行你的代码。",
|
|
297
|
+
"Enter {name} as a JSON value, such as 4, true, or \"hello\".":
|
|
298
|
+
"请将 {name} 输入为 JSON 值,例如 4、true 或 \"hello\"。",
|
|
299
|
+
"This function is outside the safe simulation subset: {error}":
|
|
300
|
+
"此函数使用了安全模拟范围之外的语法:{error}",
|
|
301
|
+
"Python source must be text.": "Python 源码必须是文本。",
|
|
302
|
+
"The value for {name} is nested too deeply.":
|
|
303
|
+
"{name} 的值嵌套层级过深。",
|
|
304
|
+
"The value for {name} is too long.": "{name} 的值过长。",
|
|
305
|
+
"The value for {name} is too large.": "{name} 的值过大。",
|
|
306
|
+
"The value for {name} must be a finite number.":
|
|
307
|
+
"{name} 必须是有限数值。",
|
|
308
|
+
"The value for {name} has too many items.":
|
|
309
|
+
"{name} 包含的项目过多。",
|
|
310
|
+
"The value for {name} must be a small object with string keys.":
|
|
311
|
+
"{name} 必须是键为字符串且规模较小的对象。",
|
|
312
|
+
"The value for {name} must be a JSON value.":
|
|
313
|
+
"{name} 必须是有效的 JSON 值。",
|
|
314
|
+
"Arguments must be an object with parameter names and values.":
|
|
315
|
+
"参数必须是由参数名和值组成的对象。",
|
|
316
|
+
"Too many function arguments.": "函数参数过多。",
|
|
317
|
+
"Argument names must be valid parameter names.":
|
|
318
|
+
"参数名必须是有效的标识符。",
|
|
319
|
+
"This function has no supported steps to simulate.":
|
|
320
|
+
"此函数没有可模拟的受支持步骤。",
|
|
321
|
+
"This program has no executable top-level statements.":
|
|
322
|
+
"此程序没有可执行的顶层语句。",
|
|
323
|
+
"The requested POV step does not exist.": "请求的 POV 步骤不存在。",
|
|
324
|
+
"Program output exceeded the safe size limit.":
|
|
325
|
+
"程序输出超过了安全大小限制。",
|
|
326
|
+
"Python source exceeds the safe simulation limit of {limit} characters.":
|
|
327
|
+
"Python 源码超过安全模拟长度上限({limit} 个字符)。",
|
|
328
|
+
"Python code could not be simulated safely. Check the syntax and supported subset.":
|
|
329
|
+
"无法安全模拟此 Python 代码。请检查语法,并确认代码使用了受支持的语法。",
|
|
330
|
+
"Python code could not be simulated at line {line}. Check the syntax and supported subset.":
|
|
331
|
+
"无法安全模拟第 {line} 行。请检查语法,并确认代码使用了受支持的语法。",
|
|
332
|
+
"This Python operation is outside the supported simulation subset at line {line}.":
|
|
333
|
+
"第 {line} 行的 Python 操作超出了模拟器的支持范围。",
|
|
334
|
+
"The simulation reached the {limit}-step safety limit.":
|
|
335
|
+
"模拟达到 {limit} 步的安全上限。",
|
|
336
|
+
"The program exceeded the {limit}-iteration loop safety limit.":
|
|
337
|
+
"程序超过了 {limit} 次循环迭代的安全上限。",
|
|
338
|
+
"A loop exceeded the {limit}-iteration safety limit.":
|
|
339
|
+
"循环超过了 {limit} 次迭代的安全上限。",
|
|
340
|
+
"The call depth exceeded the safe limit of {limit}.":
|
|
341
|
+
"函数调用深度超过安全上限 {limit}。",
|
|
342
|
+
"The simulation could not safely continue. Check the code and input values.":
|
|
343
|
+
"模拟无法安全继续。请检查代码和输入值。",
|
|
344
|
+
"JSON input is too long (maximum {limit} characters).":
|
|
345
|
+
"JSON 输入过长(最多 {limit} 个字符)。",
|
|
346
|
+
"This JSON value is too large, too deeply nested, or not finite.":
|
|
347
|
+
"此 JSON 值过大、嵌套过深,或不是有限数值。",
|
|
348
|
+
"STEP {current} OF {total} · {function}":
|
|
349
|
+
"第 {current}/{total} 步 · {function}",
|
|
350
|
+
"{function} · {file}": "{function} · {file}",
|
|
351
|
+
"Follow the current function state.": "查看当前函数状态。",
|
|
352
|
+
"Finish ✓": "完成 ✓",
|
|
353
|
+
"Next →": "下一步 →",
|
|
354
|
+
"You are now {function}. The caller passed these arguments.":
|
|
355
|
+
"现在你是 {function}。调用者传入了这些参数。",
|
|
356
|
+
"Work out the value assigned to {target}.": "计算赋给 {target} 的值。",
|
|
357
|
+
"Bind the expression result to {target}.": "将表达式结果存入 {target}。",
|
|
358
|
+
"Does this condition evaluate to True or False?": "这个条件的结果是 True 还是 False?",
|
|
359
|
+
"Which project function is being called here?": "这里调用的是哪个项目函数?",
|
|
360
|
+
"The called function returned. Its value is back with you.":
|
|
361
|
+
"被调用的函数已经返回,返回值已交还给你。",
|
|
362
|
+
"What value does {function} return to its caller?": "{function} 会向调用者返回什么值?",
|
|
363
|
+
"Follow the highlighted line, then continue.": "跟随高亮代码行,然后继续。",
|
|
364
|
+
"Follow the highlighted line. Continue when you are ready.":
|
|
365
|
+
"跟随高亮代码行,准备好后继续。",
|
|
366
|
+
"Review the caller's values and local state, then continue.":
|
|
367
|
+
"查看调用者传入的值和局部状态,然后继续。",
|
|
368
|
+
"The nested call has returned. Continue with the result shown.":
|
|
369
|
+
"嵌套调用已返回,请根据显示的结果继续。",
|
|
370
|
+
"Calculate the result using the values shown.": "根据显示的值计算结果。",
|
|
371
|
+
"Choose the branch that matches this condition.": "选择符合此条件的分支。",
|
|
372
|
+
"Choose the function called at this line.": "选择此行调用的函数。",
|
|
373
|
+
"Enter the value being returned. Use JSON for text or collections.":
|
|
374
|
+
"输入函数将要返回的值。文本或集合请使用 JSON 格式。",
|
|
375
|
+
"Enter your answer as a JSON value.": "请以 JSON 值的格式输入答案。",
|
|
376
|
+
"This challenge is complete. You can review your answer history.":
|
|
377
|
+
"本题已完成。你可以查看答题记录。",
|
|
378
|
+
"Enter an answer before checking it.": "请先输入答案再进行检查。",
|
|
379
|
+
"Use a JSON value: for example 4, true, or \"hello\".":
|
|
380
|
+
"请使用 JSON 值,例如 4、true 或 \"hello\"。",
|
|
381
|
+
"Correct": "正确",
|
|
382
|
+
"Try again": "再试一次",
|
|
383
|
+
"Attempt {number}: {answer} · {status}": "第 {number} 次:{answer} · {status}",
|
|
384
|
+
"Answer revealed: {answer}": "已显示答案:{answer}",
|
|
385
|
+
"Correct. {answer} is the value for this step.": "回答正确!此步骤的值是 {answer}。",
|
|
386
|
+
"Not quite. Compare your answer with the highlighted expression and current values, then try again.":
|
|
387
|
+
"还不正确。请对照高亮表达式和当前变量值,再试一次。",
|
|
388
|
+
"Substitute the local values into the expression, then follow operator order.":
|
|
389
|
+
"将局部变量代入表达式,并按运算符优先级计算。",
|
|
390
|
+
"Substitute the local values and compare them to choose the matching branch.":
|
|
391
|
+
"代入局部变量并进行比较,选择符合条件的分支。",
|
|
392
|
+
"Look at the function name immediately before the parentheses.":
|
|
393
|
+
"查看括号前面的函数名称。",
|
|
394
|
+
"Evaluate the return expression using the local variables shown.":
|
|
395
|
+
"使用显示的局部变量计算 return 表达式。",
|
|
396
|
+
"Answer: {answer}. Review the highlighted line before continuing.":
|
|
397
|
+
"答案:{answer}。继续前请回顾高亮代码行。",
|
|
398
|
+
"Function: {function}\nChallenges: {total} · Solved by you: {solved} · "
|
|
399
|
+
"Answers revealed: {revealed} · Attempts: {attempts}{practice}\nFinal return value: {value}":
|
|
400
|
+
"函数:{function}\n挑战:{total} · 自行答对:{solved} · 查看答案:{revealed} · "
|
|
401
|
+
"作答次数:{attempts}{practice}\n最终返回值:{value}",
|
|
402
|
+
"No explicit return value.": "没有显式返回值。",
|
|
403
|
+
"FUNCTION POV": "函数 POV",
|
|
404
|
+
"Function POV currently supports Python only; this analysis uses {language}.":
|
|
405
|
+
"函数 POV 目前只支持 Python;当前分析的语言是 {language}。",
|
|
406
|
+
# -- compare -------------------------------------------------------
|
|
407
|
+
"Before file…": "修改前的文件…",
|
|
408
|
+
"After file…": "修改后的文件…",
|
|
409
|
+
"Sample pair": "示例对",
|
|
410
|
+
"Swap": "交换",
|
|
411
|
+
"Compare": "开始对比",
|
|
412
|
+
"Pick two versions of the same file to see the structural diff.":
|
|
413
|
+
"选同一个文件的两个版本,看结构上的差异。",
|
|
414
|
+
"Select a symbol": "选中一个符号",
|
|
415
|
+
"Before": "修改前",
|
|
416
|
+
"After": "修改后",
|
|
417
|
+
"All symbols": "全部符号",
|
|
418
|
+
"Added": "新增",
|
|
419
|
+
"Removed": "删除",
|
|
420
|
+
"Modified": "修改",
|
|
421
|
+
"Moved": "改名移动",
|
|
422
|
+
"Unchanged": "未变",
|
|
423
|
+
"Choose both files first.": "先选好两个文件。",
|
|
424
|
+
"Comparing…": "正在对比…",
|
|
425
|
+
"No classes or functions found in either file.": "两个文件里都没找到类或函数。",
|
|
426
|
+
"Choose the before file": "选择修改前的文件",
|
|
427
|
+
"Choose the after file": "选择修改后的文件",
|
|
428
|
+
"Source files": "源文件",
|
|
429
|
+
"All files": "所有文件",
|
|
430
|
+
"(no before file)": "(尚未选择修改前的文件)",
|
|
431
|
+
"(no after file)": "(尚未选择修改后的文件)",
|
|
432
|
+
"Could not compare: {error}": "无法对比:{error}",
|
|
433
|
+
"Could not read {name}: {error}": "无法读取 {name}:{error}",
|
|
434
|
+
"Sample: {old} → {new}": "示例:{old} → {new}",
|
|
435
|
+
"{name}: pick a before file and an after file.":
|
|
436
|
+
"{name}:选一个修改前和一个修改后的文件。",
|
|
437
|
+
"No bundled sample for {name} yet — pick two files.":
|
|
438
|
+
"暂时没有 {name} 的示例对 — 请自行选两个文件。",
|
|
439
|
+
"Sample files are missing: {error}": "示例文件丢了:{error}",
|
|
440
|
+
"structscope is not installed — see README, section “Compare two versions”":
|
|
441
|
+
"没有安装 structscope — 见 README 的“Compare two versions”一节",
|
|
442
|
+
},
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
_current = "en"
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
def language() -> str:
|
|
449
|
+
"""Current interface language code."""
|
|
450
|
+
return _current
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
def set_language(code: str) -> None:
|
|
454
|
+
"""Switch the interface language; unknown codes fall back to English."""
|
|
455
|
+
global _current
|
|
456
|
+
_current = code if code in _TABLES else "en"
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
def language_name(code: str) -> str:
|
|
460
|
+
for known, label in LANGUAGES:
|
|
461
|
+
if known == code:
|
|
462
|
+
return label
|
|
463
|
+
return code
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
def tr(text: str, **fields) -> str:
|
|
467
|
+
"""Translate ``text``; formatted fields are applied after lookup."""
|
|
468
|
+
translated = _TABLES.get(_current, {}).get(text, text)
|
|
469
|
+
if fields:
|
|
470
|
+
try:
|
|
471
|
+
return translated.format(**fields)
|
|
472
|
+
except (KeyError, IndexError, ValueError):
|
|
473
|
+
return translated
|
|
474
|
+
return translated
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
def simulation_error_text(message: str) -> str:
|
|
478
|
+
"""Translate common simulator errors without exposing raw English in Chinese UI."""
|
|
479
|
+
if _current == "en":
|
|
480
|
+
return message
|
|
481
|
+
|
|
482
|
+
translated = _TABLES["zh"].get(message)
|
|
483
|
+
if translated is not None:
|
|
484
|
+
return translated
|
|
485
|
+
|
|
486
|
+
match = re.fullmatch(
|
|
487
|
+
r"The (?:source|program) is too long to simulate safely "
|
|
488
|
+
r"\(limit: ([\d,]+) characters\)\.",
|
|
489
|
+
message,
|
|
490
|
+
)
|
|
491
|
+
if match:
|
|
492
|
+
return tr(
|
|
493
|
+
"Python source exceeds the safe simulation limit of {limit} characters.",
|
|
494
|
+
limit=match.group(1),
|
|
495
|
+
)
|
|
496
|
+
|
|
497
|
+
value_error_patterns = (
|
|
498
|
+
(r"(.+) is nested too deeply\.", "The value for {name} is nested too deeply."),
|
|
499
|
+
(r"(.+) is too long\.", "The value for {name} is too long."),
|
|
500
|
+
(r"(.+) is too large\.", "The value for {name} is too large."),
|
|
501
|
+
(r"(.+) must be a finite number\.", "The value for {name} must be a finite number."),
|
|
502
|
+
(r"(.+) has too many items\.", "The value for {name} has too many items."),
|
|
503
|
+
(
|
|
504
|
+
r"(.+) must be a small object with string keys\.",
|
|
505
|
+
"The value for {name} must be a small object with string keys.",
|
|
506
|
+
),
|
|
507
|
+
(r"(.+) must be a JSON value\.", "The value for {name} must be a JSON value."),
|
|
508
|
+
)
|
|
509
|
+
for pattern, key in value_error_patterns:
|
|
510
|
+
match = re.fullmatch(pattern, message)
|
|
511
|
+
if match:
|
|
512
|
+
return tr(key, name=match.group(1))
|
|
513
|
+
|
|
514
|
+
limit_patterns = (
|
|
515
|
+
(
|
|
516
|
+
r"The simulation reached its safe limit of (\d+) steps\.",
|
|
517
|
+
"The simulation reached the {limit}-step safety limit.",
|
|
518
|
+
),
|
|
519
|
+
(
|
|
520
|
+
r"The program exceeds the safe limit of (\d+) total loop iterations\.",
|
|
521
|
+
"The program exceeded the {limit}-iteration loop safety limit.",
|
|
522
|
+
),
|
|
523
|
+
(
|
|
524
|
+
r"A loop exceeds the safe limit of (\d+) iterations\.",
|
|
525
|
+
"A loop exceeded the {limit}-iteration safety limit.",
|
|
526
|
+
),
|
|
527
|
+
(
|
|
528
|
+
r"Call depth exceeded the safe limit of (\d+)\.",
|
|
529
|
+
"The call depth exceeded the safe limit of {limit}.",
|
|
530
|
+
),
|
|
531
|
+
)
|
|
532
|
+
for pattern, key in limit_patterns:
|
|
533
|
+
match = re.fullmatch(pattern, message)
|
|
534
|
+
if match:
|
|
535
|
+
return tr(key, limit=match.group(1))
|
|
536
|
+
|
|
537
|
+
syntax_error = re.match(
|
|
538
|
+
r"Cannot simulate (?:pasted )?Python(?: on line (\d+))?: ",
|
|
539
|
+
message,
|
|
540
|
+
)
|
|
541
|
+
if syntax_error:
|
|
542
|
+
line = syntax_error.group(1)
|
|
543
|
+
if line:
|
|
544
|
+
return tr(
|
|
545
|
+
"Python code could not be simulated at line {line}. "
|
|
546
|
+
"Check the syntax and supported subset.",
|
|
547
|
+
line=line,
|
|
548
|
+
)
|
|
549
|
+
return tr(
|
|
550
|
+
"Python code could not be simulated safely. "
|
|
551
|
+
"Check the syntax and supported subset."
|
|
552
|
+
)
|
|
553
|
+
|
|
554
|
+
unsupported_line = re.search(r"\bat line (\d+)$", message)
|
|
555
|
+
if unsupported_line:
|
|
556
|
+
return tr(
|
|
557
|
+
"This Python operation is outside the supported simulation subset "
|
|
558
|
+
"at line {line}.",
|
|
559
|
+
line=unsupported_line.group(1),
|
|
560
|
+
)
|
|
561
|
+
|
|
562
|
+
return tr(
|
|
563
|
+
"The simulation could not safely continue. Check the code and input values."
|
|
564
|
+
)
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
def untranslated(keys: Iterable[str]) -> List[str]:
|
|
568
|
+
"""Keys with no translation in any language but English (for tests)."""
|
|
569
|
+
translated = set(_TABLES["zh"])
|
|
570
|
+
return [key for key in keys if key not in translated]
|
python_app/installer.nsi
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Unicode true
|
|
2
|
+
!include "MUI2.nsh"
|
|
3
|
+
|
|
4
|
+
!ifndef APP_VERSION
|
|
5
|
+
!define APP_VERSION "1.0.0"
|
|
6
|
+
!endif
|
|
7
|
+
!ifndef PAYLOAD_DIR
|
|
8
|
+
!define PAYLOAD_DIR "..\dist\Prism"
|
|
9
|
+
!endif
|
|
10
|
+
!ifndef OUT_FILE
|
|
11
|
+
!define OUT_FILE "..\installer\Prism-Python-Setup-1.0.0.exe"
|
|
12
|
+
!endif
|
|
13
|
+
|
|
14
|
+
Name "Prism"
|
|
15
|
+
OutFile "${OUT_FILE}"
|
|
16
|
+
InstallDir "$LOCALAPPDATA\Programs\Prism"
|
|
17
|
+
InstallDirRegKey HKCU "Software\Prism" "InstallDir"
|
|
18
|
+
RequestExecutionLevel user
|
|
19
|
+
SetCompressor /SOLID lzma
|
|
20
|
+
BrandingText "Prism · Python desktop workspace"
|
|
21
|
+
|
|
22
|
+
!define MUI_ABORTWARNING
|
|
23
|
+
!define MUI_ICON "${__FILEDIR__}\..\assets\icon.ico"
|
|
24
|
+
!define MUI_UNICON "${__FILEDIR__}\..\assets\icon.ico"
|
|
25
|
+
!insertmacro MUI_PAGE_WELCOME
|
|
26
|
+
!insertmacro MUI_PAGE_DIRECTORY
|
|
27
|
+
!insertmacro MUI_PAGE_INSTFILES
|
|
28
|
+
!insertmacro MUI_PAGE_FINISH
|
|
29
|
+
!insertmacro MUI_UNPAGE_CONFIRM
|
|
30
|
+
!insertmacro MUI_UNPAGE_INSTFILES
|
|
31
|
+
|
|
32
|
+
!insertmacro MUI_LANGUAGE "English"
|
|
33
|
+
|
|
34
|
+
VIProductVersion "1.0.0.0"
|
|
35
|
+
VIAddVersionKey "ProductName" "Prism"
|
|
36
|
+
VIAddVersionKey "FileDescription" "Prism code analysis workspace"
|
|
37
|
+
VIAddVersionKey "FileVersion" "1.0.0"
|
|
38
|
+
VIAddVersionKey "ProductVersion" "1.0.0"
|
|
39
|
+
VIAddVersionKey "LegalCopyright" "Prism"
|
|
40
|
+
|
|
41
|
+
Section "Prism" SecMain
|
|
42
|
+
SetOutPath "$INSTDIR"
|
|
43
|
+
File /r "${PAYLOAD_DIR}\*.*"
|
|
44
|
+
|
|
45
|
+
CreateDirectory "$SMPROGRAMS\Prism"
|
|
46
|
+
CreateShortcut "$SMPROGRAMS\Prism\Prism.lnk" "$INSTDIR\Prism.exe" "" "$INSTDIR\Prism.exe" 0
|
|
47
|
+
CreateShortcut "$SMPROGRAMS\Prism\Uninstall Prism.lnk" "$INSTDIR\Uninstall Prism.exe"
|
|
48
|
+
CreateShortcut "$DESKTOP\Prism.lnk" "$INSTDIR\Prism.exe" "" "$INSTDIR\Prism.exe" 0
|
|
49
|
+
|
|
50
|
+
WriteUninstaller "$INSTDIR\Uninstall Prism.exe"
|
|
51
|
+
WriteRegStr HKCU "Software\Prism" "InstallDir" "$INSTDIR"
|
|
52
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Prism" "DisplayName" "Prism"
|
|
53
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Prism" "DisplayVersion" "${APP_VERSION}"
|
|
54
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Prism" "Publisher" "Prism"
|
|
55
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Prism" "DisplayIcon" "$INSTDIR\Prism.exe"
|
|
56
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Prism" "UninstallString" '"$INSTDIR\Uninstall Prism.exe"'
|
|
57
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Prism" "InstallLocation" "$INSTDIR"
|
|
58
|
+
WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Prism" "NoModify" 1
|
|
59
|
+
WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Prism" "NoRepair" 1
|
|
60
|
+
SectionEnd
|
|
61
|
+
|
|
62
|
+
Section "Uninstall"
|
|
63
|
+
Delete "$DESKTOP\Prism.lnk"
|
|
64
|
+
Delete "$SMPROGRAMS\Prism\Prism.lnk"
|
|
65
|
+
Delete "$SMPROGRAMS\Prism\Uninstall Prism.lnk"
|
|
66
|
+
RMDir "$SMPROGRAMS\Prism"
|
|
67
|
+
RMDir /r "$INSTDIR"
|
|
68
|
+
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Prism"
|
|
69
|
+
DeleteRegKey HKCU "Software\Prism"
|
|
70
|
+
SectionEnd
|