Project

General

Profile

« Previous | Next » 

Revision c1c7f969

Added by koszko over 1 year ago

fix "no translation file found for domain" error

View differences:

src/hydrilla/util/_util.py
145 145
    # https://stackoverflow.com/questions/3425294/how-to-detect-the-os-default-language-in-python
146 146
    # But I am not going to surrender to Microbugs' nonfree, crappy OS to test
147 147
    # it, to the lines inside try: may fail.
148
    try:
149
        from ctypes.windll import kernel32 as windll
150
        lang = locale.windows_locale[windll.GetUserDefaultUILanguage()]
151
    except:
152
        lang = locale.getdefaultlocale()[0] or 'C'
148
    if lang is None:
149
        try:
150
            from ctypes.windll import kernel32 as windll
151
            lang = locale.windows_locale[windll.GetUserDefaultUILanguage()]
152
        except:
153
            lang = locale.getdefaultlocale()[0] or 'en_US'
154

  
155
    localedir = Path(localedir)
156
    if not (localedir / lang).is_dir():
157
        lang = 'en_US'
153 158

  
154 159
    return gettext.translation('hydrilla-messages', localedir=localedir,
155
                               languages=[lang, 'en_US'])
160
                               languages=[lang])
156 161

  
157 162
_ = translation(here.parent / 'builder' / 'locales').gettext

Also available in: Unified diff