@@ -59,20 +59,202 @@ def path_to_languages_folder():
5959 #the user preferences file is stored at: MathCAT\Rules\Languages
6060 return os .path .expanduser ('~' )+ "\\ AppData\\ Roaming\\ nvda\\ addons\\ mathCAT\\ globalPlugins\\ MathCAT\\ Rules\\ Languages"
6161
62+ def LanguagesDict ():
63+ languages = {
64+ "aa" : "Afar" ,
65+ "ab" : "Аҧсуа" ,
66+ "af" : "Afrikaans" ,
67+ "ak" : "Akana" ,
68+ "an" : "Aragonés" ,
69+ "ar" : "العربية" ,
70+ "as" : "অসমীয়া" ,
71+ "av" : "Авар" ,
72+ "ay" : "Aymar" ,
73+ "az" : "Azərbaycanca / آذربايجان" ,
74+ "ba" : "Башҡорт" ,
75+ "be" : "Беларуская" ,
76+ "bg" : "Български" ,
77+ "bh" : "भोजपुरी" ,
78+ "bi" : "Bislama" ,
79+ "bm" : "Bamanankan" ,
80+ "bn" : "বাংলা" ,
81+ "bo" : "བོད་ཡིག / Bod skad" ,
82+ "bs" : "Bosanski" ,
83+ "ca" : "Català" ,
84+ "ce" : "Нохчийн" ,
85+ "ch" : "Chamoru" ,
86+ "co" : "Corsu" ,
87+ "cr" : "Nehiyaw" ,
88+ "cs" : "Česky" ,
89+ "cu" : "словѣньскъ / slověnĭskŭ" ,
90+ "cv" : "Чăваш" ,
91+ "cy" : "Cymraeg" ,
92+ "da" : "Dansk" ,
93+ "de" : "Deutsch" ,
94+ "dv" : "ދިވެހިބަސް" ,
95+ "dz" : "རྫོང་ཁ" ,
96+ "ee" : "Ɛʋɛ" ,
97+ "en" : "English" ,
98+ "eo" : "Esperanto" ,
99+ "es" : "Español" ,
100+ "fa" : "فارسی" ,
101+ "fi" : "Suomi" ,
102+ "fj" : "Na Vosa Vakaviti" ,
103+ "fo" : "Føroyskt" ,
104+ "fr" : "Français" ,
105+ f"ur" : "Furlan" ,
106+ "fy" : "Frysk" ,
107+ "ga" : "Gaeilge" ,
108+ "gd" : "Gàidhlig" ,
109+ "gl" : "Galego" ,
110+ "gn" : "Avañe'ẽ" ,
111+ "gu" : "ગુજરાતી" ,
112+ "gv" : "Gaelg" ,
113+ "ha" : "هَوُسَ" ,
114+ "he" : "עברית" ,
115+ "hi" : "हिन्दी" ,
116+ "ho" : "Hiri Motu" ,
117+ "hr" : "Hrvatski" ,
118+ "ht" : "Krèyol ayisyen" ,
119+ "hu" : "Magyar" ,
120+ "hy" : "Հայերեն" ,
121+ "hz" : "Otsiherero" ,
122+ "ia" : "Interlingua" ,
123+ "id" : "Bahasa Indonesia" ,
124+ "ig" : "Igbo" ,
125+ "ii" : "ꆇꉙ / 四川彝语" ,
126+ "ik" : "Iñupiak" ,
127+ "io" : "Ido" ,
128+ "is" : "Íslenska" ,
129+ "iu" : "ᐃᓄᒃᑎᑐᑦ" ,
130+ "ja" : "日本語" ,
131+ "jv" : "Basa Jawa" ,
132+ "ka" : "ქართული" ,
133+ "kg" : "KiKongo" ,
134+ "ki" : "Gĩkũyũ" ,
135+ "kj" : "Kuanyama" ,
136+ "kk" : "Қазақша" ,
137+ "km" : "ភាសាខ្មែរ" ,
138+ "kn" : "ಕನ್ನಡ" ,
139+ "ko" : "한국어" ,
140+ "ks" : "कॉशुर / کٲش" ,
141+ "ku" : "Kurdî" ,
142+ "kv" : "Коми" ,
143+ "kw" : "Kernewek" ,
144+ "ky" : "Kırgızca / Кыргызча" ,
145+ "la" : "Latina" ,
146+ "lb" : "Lëtzebuergesch" ,
147+ "lg" : "Luganda" ,
148+ "li" : "Limburgs" ,
149+ "ln" : "Lingála" ,
150+ "lo" : "ລາວ / Pha xa lao" ,
151+ "lt" : "Lietuvių" ,
152+ "lv" : "Latviešu" ,
153+ "mg" : "Malagasy" ,
154+ "mh" : "Kajin Majel / Ebon" ,
155+ "mk" : "Македонски" ,
156+ "ml" : "മലയാളം" ,
157+ "mn" : "Монгол" ,
158+ "mo" : "Moldovenească" ,
159+ "ms" : "Bahasa Melayu" ,
160+ "mt" : "bil-Malti" ,
161+ "my" : "Myanmasa" ,
162+ "na" : "Dorerin Naoero" ,
163+ "ne" : "नेपाली" ,
164+ "ng" : "Oshiwambo" ,
165+ "nl" : "Nederlands" ,
166+ "nn" : "Norsk (nynorsk)" ,
167+ "nr" : "isiNdebele" ,
168+ "nv" : "Diné bizaad" ,
169+ "ny" : "Chi-Chewa" ,
170+ "oc" : "Occitan" ,
171+ "oj" : "ᐊᓂᔑᓈᐯᒧᐎᓐ / Anishinaabemowin" ,
172+ "om" : "Oromoo" ,
173+ "os" : "Иронау" ,
174+ "pa" : "ਪੰਜਾਬੀ / پنجابی" ,
175+ "pi" : "Pāli / पाऴि" ,
176+ "pl" : "Polski" ,
177+ "ps" : "پښتو" ,
178+ "pt" : "Português" ,
179+ "qu" : "Runa Simi" ,
180+ "rm" : "Rumantsch" ,
181+ "ro" : "Română" ,
182+ "ru" : "Русский" ,
183+ "rw" : "Kinyarwandi" ,
184+ "sa" : "संस्कृतम्" ,
185+ "sc" : "Sardu" ,
186+ "sd" : "सिंधी / سنڌي" ,
187+ "se" : "Davvisámegiella" ,
188+ "sg" : "Sängö" ,
189+ "sh" : "Srpskohrvatski / Српскохрватски" ,
190+ "si" : "සිංහල" ,
191+ "sk" : "Slovenčina" ,
192+ "sl" : "Slovenščina" ,
193+ "sm" : "Gagana Samoa" ,
194+ "sn" : "chiShona" ,
195+ "so" : "Soomaaliga" ,
196+ "sq" : "Shqip" ,
197+ "sr" : "Српски" ,
198+ "ss" : "SiSwati" ,
199+ "st" : "Sesotho" ,
200+ "su" : "Basa Sunda" ,
201+ "sv" : "Svenska" ,
202+ "sw" : "Kiswahili" ,
203+ "ta" : "தமிழ்" ,
204+ "tg" : "Тоҷикӣ" ,
205+ "th" : "ไทย / Phasa Thai" ,
206+ "ti" : "ትግርኛ" ,
207+ "tk" : "Туркмен / تركمن" ,
208+ "tl" : "Tagalog" ,
209+ "to" : "Lea Faka-Tonga" ,
210+ "tr" : "Türkçe" ,
211+ "ts" : "Xitsonga" ,
212+ "tt" : "Tatarça" ,
213+ "tw" : "Twi" ,
214+ "ty" : "Reo Mā`ohi" ,
215+ "ug" : "Uyƣurqə / ئۇيغۇرچە" ,
216+ "uk" : "Українська" ,
217+ "ur" : "اردو" ,
218+ "uz" : "Ўзбек" ,
219+ "ve" : "Tshivenḓa" ,
220+ "vi" : "Tiếng Việt" ,
221+ "vo" : "Volapük" ,
222+ "wa" : "Walon" ,
223+ "wo" : "Wollof" ,
224+ "xh" : "isiXhosa" ,
225+ "yi" : "ייִדיש" ,
226+ "yo" : "Yorùbá" ,
227+ "za" : "Cuengh / Tôô / 壮语" ,
228+ "zh" : "中文" ,
229+ "zu" : "isiZulu"
230+ }
231+ return languages
232+
62233 def GetLanguages (self ):
63- #clear the language choices
234+ # initialise the language list
235+ languages_dict = UserInterface .LanguagesDict ()
236+ #clear the language names in the dialog
64237 self .m_choiceLanguage .Clear ()
65- #populate the language choices
238+ #populate the available language names in the dialog
66239 for f in os .listdir (UserInterface .path_to_languages_folder ()):
67- if os .path .isdir (UserInterface .path_to_languages_folder ()+ "\\ " + f ):
68- self .m_choiceLanguage .Append (f )
240+ if os .path .isdir (UserInterface .path_to_languages_folder ()+ "\\ " + f ):
241+ if languages_dict .get (f , 'missing' ) == 'missing' :
242+ self .m_choiceLanguage .Append (f + " (" + f + ")" )
243+ else :
244+ self .m_choiceLanguage .Append (languages_dict [f ] + " (" + f + ")" )
245+
246+ def GetLanguageCode (self ):
247+ langselection = self .m_choiceLanguage .GetStringSelection ()
248+ langcode = langselection [langselection .find ("(" )+ 1 : langselection .find (")" )]
249+ return langcode
69250
70251 def GetSpeechStyles (self , this_SpeechStyle ):
71252 #clear the SpeechStyle choices
72253 self .m_choiceSpeechStyle .Clear ()
73- #get the currently selected language
74- this_language = self .m_choiceLanguage .GetStringSelection ()
75- this_path = os .path .expanduser ('~' )+ "\\ AppData\\ Roaming\\ nvda\\ addons\\ MathCAT\\ globalPlugins\\ MathCAT\\ Rules\\ Languages\\ " + this_language + "\\ *_Rules.yaml"
254+ #get the currently selected language code
255+ this_language_code = UserInterface .GetLanguageCode (self )
256+
257+ this_path = os .path .expanduser ('~' )+ "\\ AppData\\ Roaming\\ nvda\\ addons\\ MathCAT\\ globalPlugins\\ MathCAT\\ Rules\\ Languages\\ " + this_language_code + "\\ *_Rules.yaml"
76258 #populate the m_choiceSpeechStyle choices
77259 for f in glob .glob (this_path ):
78260 fname = os .path .basename (f )
@@ -89,12 +271,24 @@ def set_ui_values(self):
89271 try :
90272 self .m_choiceImpairment .SetSelection (Speech_Impairment .index (user_preferences ["Speech" ]["Impairment" ]))
91273 try :
92- self .m_choiceLanguage .SetStringSelection (user_preferences ["Speech" ]["Language" ])
274+ langpref = user_preferences ["Speech" ]["Language" ]
275+ i = 0
276+ while "(" + langpref + ")" not in self .m_choiceLanguage .GetString (i ):
277+ i = i + 1
278+ if i == self .m_choiceLanguage .GetCount ():
279+ break
280+ if "(" + langpref + ")" in self .m_choiceLanguage .GetString (i ):
281+ self .m_choiceLanguage .SetSelection (i )
282+ else :
283+ self .m_choiceLanguage .SetSelection (0 )
93284 except :
94285 #the language in the settings file is not in the folder structure, something went wrong, set to the first in the list
95286 self .m_choiceLanguage .SetSelection (0 )
96- #now get the available SpeechStyles from the folder structure and set to the preference setting is possible
97- self .GetSpeechStyles (user_preferences ["Speech" ]["SpeechStyle" ])
287+ try :
288+ #now get the available SpeechStyles from the folder structure and set to the preference setting is possible
289+ self .GetSpeechStyles (user_preferences ["Speech" ]["SpeechStyle" ])
290+ except :
291+ self .m_choiceSpeechStyle .Append ("Error when setting SpeechStyle for " + self .m_choiceLanguage .GetStringSelection ())
98292 #set the rest of the UI elements
99293 self .m_choiceSpeechAmount .SetSelection (Speech_Verbosity .index (user_preferences ["Speech" ]["Verbosity" ]))
100294 self .m_sliderRelativeSpeed .SetValue (user_preferences ["Speech" ]["MathRate" ])
@@ -119,7 +313,7 @@ def get_ui_values(self):
119313 global user_preferences
120314 # read the values from the UI and update the user preferences dictionary
121315 user_preferences ["Speech" ]["Impairment" ] = Speech_Impairment [self .m_choiceImpairment .GetSelection ()]
122- user_preferences ["Speech" ]["Language" ] = self .m_choiceLanguage . GetStringSelection ()
316+ user_preferences ["Speech" ]["Language" ] = self .GetLanguageCode ()
123317 user_preferences ["Speech" ]["SpeechStyle" ] = self .m_choiceSpeechStyle .GetStringSelection ()
124318 user_preferences ["Speech" ]["Verbosity" ] = Speech_Verbosity [self .m_choiceSpeechAmount .GetSelection ()]
125319 user_preferences ["Speech" ]["MathRate" ] = self .m_sliderRelativeSpeed .GetValue ()
0 commit comments