1717from logHandler import log
1818from .constants import *
1919from . import updater
20+ from . import converter
2021
2122
2223try :
@@ -40,6 +41,8 @@ def __init__(self, *args, **kwargs):
4041
4142 # dokutar dic file path
4243 self .dictPickle = os .path .join (os .path .realpath (os .path .dirname (os .path .dirname (os .path .dirname (__file__ )))), "riryou_dict.dat" )
44+ self .dictFile = os .path .join (os .path .realpath (os .path .dirname (os .path .dirname (os .path .dirname (__file__ )))), "riryou_dict.dict" )
45+ self .dictFileSource = os .path .join (os .path .realpath (os .path .dirname (os .path .dirname (os .path .dirname (__file__ )))), "dokutor_dev.csv" )
4346
4447 if globalVars .appArgs .secure :
4548 return
@@ -97,7 +100,7 @@ def _setupMenu(self):
97100 wx .EVT_MENU , self .performUpdateCheck , self .updateCheckPerformItem )
98101
99102 self .rootMenuItem = gui .mainFrame .sysTrayIcon .menu .Insert (
100- 2 , wx .ID_ANY , _ ("DFN " ), self .rootMenu )
103+ 2 , wx .ID_ANY , _ ("読ター For NVDA " ), self .rootMenu )
101104
102105 def dictStateToggleString (self ):
103106 return _ ("理療科用読み辞書を解除する(&A)" ) if "riryou" in speechDictHandler .dictTypes else _ ("理療科用読み辞書を適用する(&A)" )
@@ -141,6 +144,7 @@ def script_changeDict(self, gesture):
141144 if "riryou" in speechDictHandler .dictTypes :
142145 self .clear ()
143146 else :
147+ tones .beep (1200 , 80 )
144148 self .load ()
145149 #Translators: Input help mode message for change dict command.
146150 script_changeDict .__doc__ = _ ("理療科用読み辞書の適用状態を切り替える" )
@@ -149,10 +153,17 @@ def toggleDictState(self, evt=None):
149153 if "riryou" in speechDictHandler .dictTypes :
150154 self .clear ()
151155 else :
156+ tones .beep (1200 , 80 )
152157 self .load ()
153158
154159 def load (self ):
155- ui .message (_ ("理療科用読み辞書を適用します。" ))
160+ # 辞書ファイル読み込みモードのときはファイルを変換
161+ if os .path .isfile (self .dictFileSource ) and (not os .path .isfile (self .dictPickle )):
162+ converter .convertFile (self .dictFileSource , self .dictFile )
163+ dic = speechDictHandler .SpeechDict ()
164+ dic .load (self .dictFile )
165+ with open (self .dictPickle , "wb" ) as f :
166+ _pickle .dump (dic , f )
156167 # 理療科辞書オブジェクト読み込み
157168 with open (self .dictPickle , "rb" ) as f :
158169 speechDictHandler .dictionaries ["riryou" ] = _pickle .load (f )
@@ -162,9 +173,9 @@ def load(self):
162173 speechDictHandler .dictTypes = tuple (ls )
163174 self .dictStateToggleItem .SetItemLabel (self .dictStateToggleString ())
164175 self .finishTone ()
176+ ui .message (_ ("理療科用読み辞書使用中。" ))
165177
166178 def clear (self ):
167- ui .message (_ ("理療科用読み辞書を解除します。" ))
168179 if "riryou" in speechDictHandler .dictTypes :
169180 # 理療科辞書タイプを削除
170181 ls = list (speechDictHandler .dictTypes )
@@ -174,6 +185,7 @@ def clear(self):
174185 del speechDictHandler .dictionaries ["riryou" ]
175186 self .dictStateToggleItem .SetItemLabel (self .dictStateToggleString ())
176187 self .finishTone ()
188+ ui .message (_ ("理療科用読み辞書解除。" ))
177189
178190 def finishTone (self ):
179191 tones .beep (1200 , 80 )
0 commit comments