add critical field checker. add workable zh-cn translation

This commit is contained in:
yyc12345 2023-07-14 15:56:35 +08:00
parent 150466966b
commit ba2b9484e3
22 changed files with 10985 additions and 4 deletions

4
.gitignore vendored
View File

@ -10,6 +10,10 @@ NlpParser/*
!NlpParser/testbench.txt
!NlpParser/README.md
NlpTr/*
!NlpTr/*.diff
!NlpTr/*.index
!NlpTr/*.json
!NlpTr/README.md
.vscode/

View File

@ -23,6 +23,39 @@ def GetTrDiffPath(ver: str) -> str:
def GetTrIndexPath(ver: str) -> str:
return f'../NlpTr/VT{ver}.index'
g_CriticalFields: dict[str, str] = {
'Common/Registry/0': 'Software\\\\Virtools\\\\Global',
'Common/Registry/1': 'Usage Count',
'Common/Timebomb/0': 'Key1',
'Common/Timebomb/1': 'Key2',
'Common/Timebomb/2': 'Key3',
'Common/Timebomb/3': 'SYSINFO.SysInfo32\\\\CLSID',
'Common/Timebomb/4': '\\\\csrsrv32.dll',
'3D Layout/Registry/0': 'Software\\\\NeMo\\\\3D Layout',
}
def CriticalFieldChecker(nlpJson: dict):
corrected: bool = False
for k, v in g_CriticalFields.items():
# analyze path and find the node
path = k.split('/')
assert path[-1].isdecimal()
path_terminal = int(path[-1])
path = path[:-1]
node = nlpJson
for pathpart in path:
node = node['key_map'][pathpart]
# check it
if node['entries'][path_terminal] != v:
# if not matched. correct it
node['entries'][path_terminal] = v
# and notify it
corrected = True
if corrected:
print('Some critical filed was changed in tr by accident. We have corrected them, but please check tr carefully')
if __name__ == "__main__":
# load each version's diff data and patch data for conventient using
@ -66,8 +99,11 @@ if __name__ == "__main__":
# convert plain json to nlp json
nlpJson = NlpUtils.PlainJson2NlpJson(plainKeys, plainValues)
# check some critical fields
CriticalFieldChecker(nlpJson)
if NlpUtils.g_EnableDebugging:
NlpUtils.RemoveKeyMapInGeneratedNlpJson(nlpJson)
NlpUtils.DumpJson(GetNlpJsonPath(ver, lang), nlpJson)
# write into file with different encoding

View File

@ -24,7 +24,7 @@ else:
def DumpJson(filepath: str, jsonData: dict):
with open(filepath, 'w', encoding='utf-8') as f:
json.dump(jsonData, f,
indent=(2 if g_EnableDebugging else None),
indent=2,
sort_keys=False,
ensure_ascii=False
)
@ -150,9 +150,11 @@ def PlainJson2NlpJson(keyList: list[str], valueList: list[str]) -> dict:
# inerate list and construct dict
for k, v in zip(keyList, valueList):
InternalPlainJson2NlpJson(result, k, v)
# remove useless key map
InternalDelNlpJsonKeyMap(result)
return result
def RemoveKeyMapInGeneratedNlpJson(nlpJson: dict) -> dict:
# remove useless key map
InternalDelNlpJsonKeyMap(nlpJson)
return nlpJson
def InternalDelNlpJsonKeyMap(nlpJson: dict):
# recursively calling self
for v in nlpJson['key_map'].values():

21
NlpTr/README.md Normal file
View File

@ -0,0 +1,21 @@
# Nlp Translation
## Create New Language Translation
These parts almost are done by repository maintainer. This is just a manual when maintainer goes.
0. First, decide your preferred language macro. I take "zh-cn" in there for example.
0. Executing `./Scripts/create_new_tr.sh "zh-cn"` in **ROOT** folder.
0. You will get a bunch of language json file named like "VT25.zh-cn.json" and listed in NlpTr folder.
0. Then navigate to NlpProc folder and register your language macro.
- `NlpUtils.py`: Add your language macro as a entry in the second declaration of `g_SupportedLangs`.
- `NlpJsonEncoder.py`: Navigate to the second declaration of `g_SupportedEncoding` In Add your macro, specify the language name shown in Virtools and, a tuple of common encoding of your language. Please note that UTF8 encoding is necessary for each language.
## How to Edit Translation
Choose your preferred translator, and fill the json correctly. I use Poedit anyway.
## How to Compile Translation
0. Executing `./Scripts/compile_tr.sh` in **ROOT** folder.
0. Then all nlp files should be generated in NlpTr/out

0
NlpTr/VT25.diff Normal file
View File

1745
NlpTr/VT25.index Normal file

File diff suppressed because it is too large Load Diff

1747
NlpTr/VT25.template.json Normal file

File diff suppressed because it is too large Load Diff

1747
NlpTr/VT25.zh-cn.json Normal file

File diff suppressed because it is too large Load Diff

41
NlpTr/VT35.diff Normal file
View File

@ -0,0 +1,41 @@
i/35
i/79
i/252
i/263
i/264
i/265
i/607
i/608
i/655
i/671
i/1227
i/1228
i/1229
i/1230
i/1231
i/1232
i/1233
i/1234
i/1235
i/1236
i/1237
i/1238
i/1333
i/1449
i/1461
i/1655
i/1765
i/1766
i/1767
i/1768
i/1769
i/1770
i/1771
i/1772
i/1773
d/1431
d/1315
d/665
d/603
d/602
d/250

1774
NlpTr/VT35.index Normal file

File diff suppressed because it is too large Load Diff

37
NlpTr/VT35.template.json Normal file
View File

@ -0,0 +1,37 @@
{
"CK/Class Names/21": "Video",
"CK/Class Names 2/21": "Videos",
"Main Menu/33": "&Refresh Windows\\tF5",
"Main Menu/44": "E&xport File",
"Main Menu/45": "&Level",
"Main Menu/46": "&Selection",
"Schematic/Dialog/17": "source of parameter <%s> (owner object : <%s>) is not in schematic\\nDo you want to show the setup of <%s> ?",
"Schematic/Dialog/18": "source of parameter <%s> (no owner object) is not in schematic\\n",
"Schematic/Popup/11": "Sort By Activity",
"Schematic/Popup/27": "Move'n'Scroll Mode\\tG",
"3D Object Setup/Buttons/3": "Use Hardware Skinning",
"3D Object Setup/Buttons/4": "Bones Mode",
"3D Object Setup/Bones Mode/0": "Local",
"3D Object Setup/Bones Mode/1": "World",
"3D Object Setup/Bones Mode/2": "World View",
"3D Object Setup/Bones Mode/3": "World View Proj",
"3D Object Setup/Bones Mode/4": "Inv Local",
"3D Object Setup/Bones Mode/5": "Inv World",
"3D Object Setup/Bones Mode/6": "Inv WorldView",
"3D Object Setup/Bones Mode/7": "Inv World View Proj",
"3D Object Setup/Bones Info/0": "Bones Count",
"3D Object Setup/Bones Info/1": "Max. Bones per Vertex",
"2D Sprite Setup/Popup Menu/6": "Save slot...",
"Mesh Setup/Buttons/20": "Material / Channel Type",
"Mesh Setup/Popup Menu/3": "Fill With...",
"Hierarchy View/Errors/3": "A place can only be a 3D root!",
"TextureType/0": "2d",
"TextureType/1": "Cube",
"TextureType/2": "Volume",
"Channel Extended/0": "Add Extended Channel",
"Channel Extended/1": "Float 1",
"Channel Extended/2": "Float 2",
"Channel Extended/3": "Float 3",
"Channel Extended/4": "Float 4",
"Channel Extended/5": "Channel Type..."
}

37
NlpTr/VT35.zh-cn.json Normal file
View File

@ -0,0 +1,37 @@
{
"CK/Class Names/21": "视频",
"CK/Class Names 2/21": "视频",
"Main Menu/33": "刷新窗口\\tF5",
"Main Menu/44": "导出文件",
"Main Menu/45": "层级",
"Main Menu/46": "选择",
"Schematic/Dialog/17": "参数<%s>的源(拥有者对象:<%s>)不在原理图中\\n您要显示<%s> 的设置吗?",
"Schematic/Dialog/18": "参数<%s>的源(无拥有者对象)不在原理图中\\n",
"Schematic/Popup/11": "按活动排序",
"Schematic/Popup/27": "移动滚动模式\\tG",
"3D Object Setup/Buttons/3": "使用硬件蒙皮",
"3D Object Setup/Buttons/4": "骨骼模式",
"3D Object Setup/Bones Mode/0": "本地",
"3D Object Setup/Bones Mode/1": "世界",
"3D Object Setup/Bones Mode/2": "世界视图",
"3D Object Setup/Bones Mode/3": "世界视图投影",
"3D Object Setup/Bones Mode/4": "反本地",
"3D Object Setup/Bones Mode/5": "反世界",
"3D Object Setup/Bones Mode/6": "反世界视图",
"3D Object Setup/Bones Mode/7": "反世界视图投影",
"3D Object Setup/Bones Info/0": "骨骼数量",
"3D Object Setup/Bones Info/1": "每个顶点的最大骨骼数",
"2D Sprite Setup/Popup Menu/6": "保存槽...",
"Mesh Setup/Buttons/20": "材质 / 通道类型",
"Mesh Setup/Popup Menu/3": "填充...",
"Hierarchy View/Errors/3": "一个位置只能是一个3D根!",
"TextureType/0": "2d",
"TextureType/1": "Cube",
"TextureType/2": "Volume",
"Channel Extended/0": "添加扩展通道",
"Channel Extended/1": "浮点数1",
"Channel Extended/2": "浮点数2",
"Channel Extended/3": "浮点数3",
"Channel Extended/4": "浮点数4",
"Channel Extended/5": "通道类型..."
}

5
NlpTr/VT40.diff Normal file
View File

@ -0,0 +1,5 @@
i/210
i/605
i/612
d/611
d/210

1775
NlpTr/VT40.index Normal file

File diff suppressed because it is too large Load Diff

5
NlpTr/VT40.template.json Normal file
View File

@ -0,0 +1,5 @@
{
"File IO/Dialogs/24": "The Virtools file already exists, \\ndo you want to overwrite it ?",
"Schematic/Dialog/15": "Confirm Scene(s) Deletion",
"Schematic/Dialog/22": "Saving Behavioral Graphs"
}

5
NlpTr/VT40.zh-cn.json Normal file
View File

@ -0,0 +1,5 @@
{
"File IO/Dialogs/24": "Virtools 文件已经存在,\\n您要覆盖它吗?",
"Schematic/Dialog/15": "确认删除场景",
"Schematic/Dialog/22": "保存行为图"
}

68
NlpTr/VT50.diff Normal file
View File

@ -0,0 +1,68 @@
i/58
i/103
i/152
i/495
i/496
i/654
i/655
i/656
i/657
i/658
i/659
i/660
i/661
i/662
i/663
i/664
i/714
i/725
i/726
i/727
i/728
i/729
i/730
i/731
i/740
i/741
i/742
i/743
i/744
i/745
i/1077
i/1078
i/1079
i/1080
i/1081
i/1082
i/1083
i/1084
i/1085
i/1086
i/1087
i/1088
i/1175
i/1176
i/1177
i/1178
i/1179
i/1333
i/1334
i/1508
i/1509
i/1510
i/1511
i/1577
i/1578
d/728
d/727
d/726
d/725
d/657
d/656
d/655
d/654
d/653
d/652
d/651
d/650
d/150

1817
NlpTr/VT50.index Normal file

File diff suppressed because it is too large Load Diff

57
NlpTr/VT50.template.json Normal file
View File

@ -0,0 +1,57 @@
{
"CK/Class Names/44": "3D Point Cloud",
"CK/Class Names 2/44": "3D Point Clouds",
"Common/Dialogs/12": "Move to separated window\\t(Ctrl+Drag)",
"Schematic/Toolbar/5": "Show Active",
"Schematic/Toolbar/6": "Show Colored",
"Schematic/Popup/5": "Set Color\\tCtrl+R",
"Schematic/Popup/6": "Remove Color\\tCtrl+Shift+R",
"Schematic/Popup/7": "Repair",
"Schematic/Popup/8": "Sort",
"Schematic/Popup/9": "Sort By Name\\tCtrl+1",
"Schematic/Popup/10": "Sort By Owner\\tCtrl+2",
"Schematic/Popup/11": "Sort By Color\\tCtrl+3",
"Schematic/Popup/12": "Sort By Class ID\\tCtrl+4",
"Schematic/Popup/13": "Sort By Activity\\tCtrl+5",
"Schematic/Popup/14": "Sort By Priority\\tCtrl+6",
"Schematic/Popup/15": "Invert Order\\tCtrl+7",
"Schematic/Popup/65": "Alternate Paste\\tCtrl+Alt+V",
"Schematic/Popup/76": "Update all Scripts from File\\tCtrl+U",
"Schematic/Popup/77": "Update Script(s) from File\\tShift+U",
"Schematic/Popup/78": "Add Mark\\tCtrl+F2",
"Schematic/Popup/79": "Activate Script(s)",
"Schematic/Popup/80": "Deactivate Script(s)",
"Schematic/Popup/81": "Reset Script(s)",
"Schematic/Popup/82": "\\t(double-click on object icon)",
"Schematic/Tooltips/8": "Show All Scripts (Alt+1)",
"Schematic/Tooltips/9": "Hide All Scripts (Alt+2)",
"Schematic/Tooltips/10": "Hide Selected Scripts (Alt+3)",
"Schematic/Tooltips/11": "Hide Unselected Scripts (Alt+4)",
"Schematic/Tooltips/12": "Show Active Scripts Only (Alt+5)",
"Schematic/Tooltips/13": "Hide scripts which colors is not the same as those of selected scripts (Alt+6)",
"Preferences/Schematic/29": "Building Block to Replace Color",
"Preferences/Schematic/30": "Trace Color",
"Preferences/Schematic/31": "Easy Finding Parameter Operation Dialog",
"Preferences/Schematic/32": "Quick Finding Parameter Operation Dialog",
"Preferences/Schematic/33": "Path Finding Link Mode",
"Preferences/Schematic/34": "Save IOs Positions",
"Preferences/Schematic/35": "Save Parameters Positions",
"Preferences/Schematic/36": "Main",
"Preferences/Schematic/37": "Colors",
"Preferences/Schematic/38": "Automatic Scroll Delay (ms)",
"Preferences/Schematic/39": "Enable Tooltips. Delay(ms):",
"Preferences/Schematic/40": "Rollover List on Group",
"Setups/17": "Show In Level Manager",
"Setups/18": "Show In Hierarchy Manager",
"Setups/19": "Show in 3D Layout",
"Setups/20": "On Selection",
"Setups/21": "On Hierarchy",
"Material Setup/Buttons/5": "Both Sided Lighting",
"Material Setup/Buttons/6": "(OpenGL Only)",
"Mesh Setup/Blend Shapes/0": "Blend shapes weights",
"Mesh Setup/Blend Shapes/1": "Index",
"Mesh Setup/Blend Shapes/2": "Name",
"Mesh Setup/Blend Shapes/3": "Weight",
"Level View/Popup Menu/30": "Remove",
"Level View/Popup Menu/31": "Show Setup"
}

57
NlpTr/VT50.zh-cn.json Normal file
View File

@ -0,0 +1,57 @@
{
"CK/Class Names/44": "3D点云",
"CK/Class Names 2/44": "3D点云",
"Common/Dialogs/12": "移到分离窗口\\t(Ctrl+拖动)",
"Schematic/Toolbar/5": "显示活动",
"Schematic/Toolbar/6": "显示彩色",
"Schematic/Popup/5": "设置颜色\\tCtrl+R",
"Schematic/Popup/6": "移除颜色\\tCtrl+Shift+R",
"Schematic/Popup/7": "修复",
"Schematic/Popup/8": "排序",
"Schematic/Popup/9": "按名称排序\\tCtrl+1",
"Schematic/Popup/10": "按所有者排序\\tCtrl+2",
"Schematic/Popup/11": "按颜色排序\\tCtrl+3",
"Schematic/Popup/12": "按类ID排序\\tCtrl+4",
"Schematic/Popup/13": "按活动排序\\tCtrl+5",
"Schematic/Popup/14": "按优先级排序\\tCtrl+6",
"Schematic/Popup/15": "反转顺序\\tCtrl+7",
"Schematic/Popup/65": "备选粘贴\\tCtrl+Alt+V",
"Schematic/Popup/76": "从文件更新所有脚本\\tCtrl+U",
"Schematic/Popup/77": "从文件更新脚本\\tShift+U",
"Schematic/Popup/78": "添加标记\\tCtrl+F2",
"Schematic/Popup/79": "激活脚本",
"Schematic/Popup/80": "停用脚本",
"Schematic/Popup/81": "重置脚本",
"Schematic/Popup/82": "\\t(在对象图标上双击)",
"Schematic/Tooltips/8": "显示所有脚本(Alt+1)",
"Schematic/Tooltips/9": "隐藏所有脚本(Alt+2)",
"Schematic/Tooltips/10": "隐藏所选脚本(Alt+3)",
"Schematic/Tooltips/11": "隐藏未选中脚本(Alt+4)",
"Schematic/Tooltips/12": "只显示活动脚本(Alt+5)",
"Schematic/Tooltips/13": "隐藏颜色与所选脚本不同的脚本(Alt+6)",
"Preferences/Schematic/29": "替换颜色的建筑模块",
"Preferences/Schematic/30": "追踪颜色",
"Preferences/Schematic/31": "参数操作对话框易查找",
"Preferences/Schematic/32": "参数操作对话框快速查找",
"Preferences/Schematic/33": "路径查找链接模式",
"Preferences/Schematic/34": "保存IO位置",
"Preferences/Schematic/35": "保存参数位置",
"Preferences/Schematic/36": "主页",
"Preferences/Schematic/37": "颜色",
"Preferences/Schematic/38": "自动滚动延迟(毫秒)",
"Preferences/Schematic/39": "启用工具提示。延迟(毫秒):",
"Preferences/Schematic/40": "组上鼠标悬停列表",
"Setups/17": "在层管理器中显示",
"Setups/18": "在层次结构管理器中显示",
"Setups/19": "在3D布局中显示",
"Setups/20": "在选择时",
"Setups/21": "在层次结构上",
"Material Setup/Buttons/5": "双面照明",
"Material Setup/Buttons/6": "(仅OpenGL)",
"Mesh Setup/Blend Shapes/0": "混合形状权重",
"Mesh Setup/Blend Shapes/1": "索引",
"Mesh Setup/Blend Shapes/2": "名称",
"Mesh Setup/Blend Shapes/3": "权重",
"Level View/Popup Menu/30": "删除",
"Level View/Popup Menu/31": "显示设置"
}

View File

@ -1,4 +1,4 @@
cd NlpEncoder
cd NlpCodec
mkdir out
cd out
cmake ..

View File

@ -5,6 +5,7 @@ then
echo ""
echo "./create_new_tr.sh <lang-symbol>"
echo "<lang-symbol>: your preferred language symbol. such as en, de, zh-cn..."
exit 1
fi
cd NlpTr