3826: Language detection in spelling does not work, by kulath

svn: r15084
This commit is contained in:
Doug Blank 2010-04-11 14:16:54 +00:00
parent 76fbbcaab9
commit ce4a809f7b

View File

@ -171,7 +171,7 @@ LANGUAGES = {
class Spell(object): class Spell(object):
"""Attach a gtkspell instance to the passed TextView instance. """Attach a gtkspell instance to the passed TextView instance.
""" """
lang = locale.getlocale()[0] lang = locale.getlocale()[0] or "en"
_installed_languages = {'off': _('None')} _installed_languages = {'off': _('None')}
if HAVE_ENCHANT and HAVE_GTKSPELL: if HAVE_ENCHANT and HAVE_GTKSPELL:
@ -194,19 +194,15 @@ class Spell(object):
elif not HAVE_ENCHANT and HAVE_GTKSPELL: elif not HAVE_ENCHANT and HAVE_GTKSPELL:
# if lang is None, default to en: # if lang is None, default to en:
if lang == None:
locale_lang_code = "en"
else:
locale_lang_code = lang
tested = False tested = False
#we try a hack to get the locale language. #we try a hack to get the locale language.
for (lang_code, lang_name) in LANGUAGES.items(): for (lang_code, lang_name) in LANGUAGES.items():
# if this lang is the current locale: # if this lang is the current locale:
if (locale_lang_code == lang_code): if (lang == lang_code):
tested = True tested = True
# if it is english, we know it works: # if it is english, we know it works:
if locale_lang_code == "en": if lang == "en":
_installed_languages[locale_lang_code] = lang_name _installed_languages[lang] = lang_name
print _("Warning: spelling checker language limited to " print _("Warning: spelling checker language limited to "
"locale '%s'; install pyenchant/python-enchant " "locale '%s'; install pyenchant/python-enchant "
"for better options.") % "en" "for better options.") % "en"