diff --git a/src/calibre/constants.py b/src/calibre/constants.py index 0f0401f4d9..0040dd02f8 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -285,7 +285,7 @@ def get_windows_temp_path(): def get_windows_user_locale_name(): import ctypes k32 = ctypes.windll.kernel32 - n = 200 + n = 255 buf = ctypes.create_unicode_buffer(u'\0'*n) n = k32.GetUserDefaultLocaleName(buf, n) if n == 0: diff --git a/src/calibre/spell/dictionary.py b/src/calibre/spell/dictionary.py index acc5516952..766267e364 100644 --- a/src/calibre/spell/dictionary.py +++ b/src/calibre/spell/dictionary.py @@ -12,7 +12,7 @@ from operator import attrgetter from calibre.constants import plugins, config_dir from calibre.utils.config import JSONConfig -from calibre.utils.localization import get_lang, canonicalize_lang +from calibre.utils.localization import get_lang, canonicalize_lang, get_system_locale DictionaryLocale = namedtuple('DictionaryLocale', 'langcode countrycode') Dictionary = namedtuple('Dictionary', 'primary_locale locales dicpath affpath builtin name id') @@ -82,7 +82,11 @@ def custom_dictionaries(reread=False): _custom = frozenset(dics) return _custom -default_preferred_locales = {'eng':'en-US', 'deu':'de-DE', 'spa':'es-ES', 'fra':'fr-FR'} +default_en_locale = 'en-US' +ul = parse_lang_code(get_system_locale()) +if ul is not None and ul.langcode == 'eng' and ul.countrycode in 'GB BS BZ GH IE IN JM NZ TT'.split(): + default_en_locale = 'en-' + ul.countrycode +default_preferred_locales = {'eng':default_en_locale, 'deu':'de-DE', 'spa':'es-ES', 'fra':'fr-FR'} def best_locale_for_language(langcode): best_locale = dprefs['preferred_locales'].get(langcode, default_preferred_locales.get(langcode, None))