''This is to check if the access keys at end of tranlation strings are the same as in 
''source strings and if not change to the same.
''Please use it only when you exactly know what it does! 
''by gnatix
Sub main
Dim trn As PslTransList
Set trn = PSL.ActiveTransList
If trn Is Nothing Then
	MsgBox "请选择一个翻译列表！",vbOkOnly+vbInformation,"信息"
	Exit Sub
End If
If MsgBox("翻译列表 - " & trn.SourceList.Title & ":" & PSL.GetLangCode(trn.Language.LangID,pslCodeText) & Chr$(13)&Chr$(13) & "您真的想要检查该翻译列表中所有翻译字串的快捷键 " & Chr$(13) & "并将它们更改到与源字串的快捷键一样吗？",vbYesNo + vbQuestion + vbDefaultButton2, "确认") = vbNo Then Exit Sub
Dim srcstring As String
Dim trnstring As String
Dim posinsrc As Integer
Dim posintrn As Integer
Dim accesskeysrc As String
Dim accesskeytrn As String
Dim accesskey As String
Dim stringcount As Integer
Dim errorcnt As Integer
errorcnt=0
stringcnt = trn.StringCount
For i = 1 To stringcnt
Dim t As PslTransString
Set t = trn.String(i)
srcstring=Replace(t.SourceText,"&&","*a!N!d*")
trnstring=Replace(t.Text,"&&","*a!N!d*")
posinsrc=InStr(srcstring,"&")
posintrn=InStr(trnstring,"(&")
If StrComp(t.SourceText,t.Text)<>0 Then
	If posinsrc<>0 Then
		If InStr(trnstring,"&")=0 And Mid(srcstring,posinsrc+1,1)<>" " Then
			PSL.ActiveTransList.String(i).OutputError("源字串中有快捷键而翻译中却没有，请检查。")
			errorcnt=errorcnt+1
		ElseIf posintrn<>0 Then
			accesskeysrc=Mid(srcstring,posinsrc+1,1)
			accesskeytrn=Mid(trnstring,posintrn,4)
			accesskey="(&" & StrConv(accesskeysrc,vbUpperCase) & ")"
			If accesskeysrc=" " And accesskeytrn="(& )" Then
				PSL.ActiveTransList.String(i).Text=Replace(Replace(trnstring,accesskeytrn,""),"*a!N!d*","&&")
				PSL.ActiveTransList.String(i).OutputError("翻译中的快捷键" & accesskeytrn &"不对，已删除。")
				errorcnt=errorcnt+1
			ElseIf StrComp(accesskeytrn,accesskey)<>0 Then
				PSL.ActiveTransList.String(i).Text=Replace(Replace(trnstring,accesskeytrn,accesskey),"*a!N!d*","&&")
				PSL.ActiveTransList.String(i).OutputError("翻译中的快捷键" & accesskeytrn &"与源字串的不同，已更改。")
				errorcnt=errorcnt+1
			End If
		End If
	End If
End If
Next i
If errorcnt=0 Then
	PSL.Output "没有找到错误。"
Else
	PSL.Output "找到" & Str$(errorcnt) & " 个错误。"
End If
End Sub
