clean spell languages list only once. Fixes #5228

This commit is contained in:
Yann Leboulanger 2009-09-04 21:02:55 +02:00
parent c5e447fab8
commit bbb75bcdf1
1 changed files with 24 additions and 22 deletions

View File

@ -64,6 +64,17 @@ except ImportError:
#echo "{_('en'):'en'",$LANG"}"
langs = {_('English'): 'en', _('Belarusian'): 'be', _('Bulgarian'): 'bg', _('Breton'): 'br', _('Czech'): 'cs', _('German'): 'de', _('Greek'): 'el', _('British'): 'en_GB', _('Esperanto'): 'eo', _('Spanish'): 'es', _('Basque'): 'eu', _('French'): 'fr', _('Croatian'): 'hr', _('Italian'): 'it', _('Norwegian (b)'): 'nb', _('Dutch'): 'nl', _('Norwegian'): 'no', _('Polish'): 'pl', _('Portuguese'): 'pt', _('Brazilian Portuguese'): 'pt_BR', _('Russian'): 'ru', _('Serbian'): 'sr', _('Slovak'): 'sk', _('Swedish'): 'sv', _('Chinese (Ch)'): 'zh_CN'}
if gajim.config.get('use_speller') and HAS_GTK_SPELL:
# loop removing non-existent dictionaries
# iterating on a copy
tv = gtk.TextView()
spell = gtkspell.Spell(tv)
for lang in dict(langs):
try:
spell.set_language(langs[lang])
except OSError:
del langs[lang]
################################################################################
class ChatControlBase(MessageControl):
'''A base class containing a banner, ConversationTextview, MessageTextView
@ -292,18 +303,6 @@ class ChatControlBase(MessageControl):
self.msg_textview.grab_focus()
def set_speller(self):
try:
lang = gajim.config.get('speller_language')
if not lang:
lang = gajim.LANG
spell = gtkspell.Spell(self.msg_textview, lang)
# loop removing non-existant dictionaries
# iterating on a copy
for lang in dict(langs):
try:
spell.set_language(langs[lang])
except OSError:
del langs[lang]
# now set the one the user selected
per_type = 'contacts'
if self.type_id == message_control.TYPE_GC:
@ -313,9 +312,12 @@ class ChatControlBase(MessageControl):
if not lang:
# use the default one
lang = gajim.config.get('speller_language')
if not lang:
lang = gajim.LANG
if lang:
try:
gtkspell.Spell(self.msg_textview, lang)
self.msg_textview.lang = lang
spell.set_language(lang)
except (gobject.GError, RuntimeError, TypeError, OSError):
dialogs.AspellDictError(lang)