prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  locale.Error: unsupported locale setting exception when glibc locale files are not present
  **Information**
  - Solaar version: 1.0.3
  - Distribution: Fedora
  - Kernel version (ex. `uname -srmo`): `Linux 5.7.11-200.fc32.x86_64 x86_64 GNU/Linux`
  - Output of `solaar show`: N/A
  
  **Describe the bug**
  Any solaar invocation is failing with a traceback when locale.setlocale() call fails, e.g. due to missing glibc locale files for the currently set locale.
  
  **To Reproduce**
  Steps to reproduce the behavior:
  ```
  $ sudo dnf remove glibc-langpack-de
  $ export LC_ALL=de_CH.UTF-8
  $ export LANG=de_CH.UTF-8
  $ solaar --help
  Traceback (most recent call last):
    File "/usr/bin/solaar", line 59, in <module>
      import solaar.gtk
    File "/usr/lib/python3.8/site-packages/solaar/gtk.py", line 29, in <module>
      import solaar.i18n as _i18n
    File "/usr/lib/python3.8/site-packages/solaar/i18n.py", line 50, in <module>
      locale.setlocale(locale.LC_ALL, '')
    File "/usr/lib64/python3.8/locale.py", line 608, in setlocale
      return _setlocale(category, locale)
  locale.Error: unsupported locale setting
  $ 
  ```
  
  **Additional context**
  Looks like #190 is still unfixed. Downstream bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1811313 .
  
  </issue>
  <code>
  [start of lib/solaar/i18n.py]
  1 # -*- python-mode -*-
  2 # -*- coding: UTF-8 -*-
  3 
  4 ## Copyright (C) 2012-2013  Daniel Pavel
  5 ##
  6 ## This program is free software; you can redistribute it and/or modify
  7 ## it under the terms of the GNU General Public License as published by
  8 ## the Free Software Foundation; either version 2 of the License, or
  9 ## (at your option) any later version.
  10 ##
  11 ## This program is distributed in the hope that it will be useful,
  12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14 ## GNU General Public License for more details.
  15 ##
  16 ## You should have received a copy of the GNU General Public License along
  17 ## with this program; if not, write to the Free Software Foundation, Inc.,
  18 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19 
  20 from __future__ import absolute_import, division, print_function, unicode_literals
  21 
  22 import gettext as _gettext
  23 import locale
  24 
  25 from solaar import NAME as _NAME
  26 
  27 #
  28 #
  29 #
  30 
  31 
  32 def _find_locale_path(lc_domain):
  33     import os.path as _path
  34 
  35     import sys as _sys
  36     prefix_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..'))
  37     src_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..', 'share'))
  38     del _sys
  39 
  40     from glob import glob as _glob
  41 
  42     for location in prefix_share, src_share:
  43         mo_files = _glob(_path.join(location, 'locale', '*', 'LC_MESSAGES', lc_domain + '.mo'))
  44         if mo_files:
  45             return _path.join(location, 'locale')
  46 
  47     # del _path
  48 
  49 
  50 locale.setlocale(locale.LC_ALL, '')
  51 language, encoding = locale.getlocale()
  52 del locale
  53 
  54 _LOCALE_DOMAIN = _NAME.lower()
  55 path = _find_locale_path(_LOCALE_DOMAIN)
  56 
  57 _gettext.bindtextdomain(_LOCALE_DOMAIN, path)
  58 _gettext.textdomain(_LOCALE_DOMAIN)
  59 _gettext.install(_LOCALE_DOMAIN)
  60 
  61 try:
  62     unicode  # noqa: F821
  63     _ = lambda x: _gettext.gettext(x).decode('UTF-8')
  64     ngettext = lambda *x: _gettext.ngettext(*x).decode('UTF-8')
  65 except Exception:
  66     _ = _gettext.gettext
  67     ngettext = _gettext.ngettext
  68
  [end of lib/solaar/i18n.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/lib/solaar/i18n.py b/lib/solaar/i18n.py
  --- a/lib/solaar/i18n.py
  +++ b/lib/solaar/i18n.py
  @@ -47,7 +47,11 @@
       # del _path
   
   
  -locale.setlocale(locale.LC_ALL, '')
  +try:
  +    locale.setlocale(locale.LC_ALL, '')
  +except Exception:
  +    pass
  +
   language, encoding = locale.getlocale()
   del locale
  
verification_info: {"golden_diff": "diff --git a/lib/solaar/i18n.py b/lib/solaar/i18n.py\n--- a/lib/solaar/i18n.py\n+++ b/lib/solaar/i18n.py\n@@ -47,7 +47,11 @@\n     # del _path\n \n \n-locale.setlocale(locale.LC_ALL, '')\n+try:\n+    locale.setlocale(locale.LC_ALL, '')\n+except Exception:\n+    pass\n+\n language, encoding = locale.getlocale()\n del locale\n", "issue": "locale.Error: unsupported locale setting exception when glibc locale files are not present\n**Information**\r\n- Solaar version: 1.0.3\r\n- Distribution: Fedora\r\n- Kernel version (ex. `uname -srmo`): `Linux 5.7.11-200.fc32.x86_64 x86_64 GNU/Linux`\r\n- Output of `solaar show`: N/A\r\n\r\n**Describe the bug**\r\nAny solaar invocation is failing with a traceback when locale.setlocale() call fails, e.g. due to missing glibc locale files for the currently set locale.\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n```\r\n$ sudo dnf remove glibc-langpack-de\r\n$ export LC_ALL=de_CH.UTF-8\r\n$ export LANG=de_CH.UTF-8\r\n$ solaar --help\r\nTraceback (most recent call last):\r\n  File \"/usr/bin/solaar\", line 59, in <module>\r\n    import solaar.gtk\r\n  File \"/usr/lib/python3.8/site-packages/solaar/gtk.py\", line 29, in <module>\r\n    import solaar.i18n as _i18n\r\n  File \"/usr/lib/python3.8/site-packages/solaar/i18n.py\", line 50, in <module>\r\n    locale.setlocale(locale.LC_ALL, '')\r\n  File \"/usr/lib64/python3.8/locale.py\", line 608, in setlocale\r\n    return _setlocale(category, locale)\r\nlocale.Error: unsupported locale setting\r\n$ \r\n```\r\n\r\n**Additional context**\r\nLooks like #190 is still unfixed. Downstream bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1811313 .\n", "before_files": [{"content": "# -*- python-mode -*-\n# -*- coding: UTF-8 -*-\n\n## Copyright (C) 2012-2013  Daniel Pavel\n##\n## This program is free software; you can redistribute it and/or modify\n## it under the terms of the GNU General Public License as published by\n## the Free Software Foundation; either version 2 of the License, or\n## (at your option) any later version.\n##\n## This program is distributed in the hope that it will be useful,\n## but WITHOUT ANY WARRANTY; without even the implied warranty of\n## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n## GNU General Public License for more details.\n##\n## You should have received a copy of the GNU General Public License along\n## with this program; if not, write to the Free Software Foundation, Inc.,\n## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport gettext as _gettext\nimport locale\n\nfrom solaar import NAME as _NAME\n\n#\n#\n#\n\n\ndef _find_locale_path(lc_domain):\n    import os.path as _path\n\n    import sys as _sys\n    prefix_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..'))\n    src_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..', 'share'))\n    del _sys\n\n    from glob import glob as _glob\n\n    for location in prefix_share, src_share:\n        mo_files = _glob(_path.join(location, 'locale', '*', 'LC_MESSAGES', lc_domain + '.mo'))\n        if mo_files:\n            return _path.join(location, 'locale')\n\n    # del _path\n\n\nlocale.setlocale(locale.LC_ALL, '')\nlanguage, encoding = locale.getlocale()\ndel locale\n\n_LOCALE_DOMAIN = _NAME.lower()\npath = _find_locale_path(_LOCALE_DOMAIN)\n\n_gettext.bindtextdomain(_LOCALE_DOMAIN, path)\n_gettext.textdomain(_LOCALE_DOMAIN)\n_gettext.install(_LOCALE_DOMAIN)\n\ntry:\n    unicode  # noqa: F821\n    _ = lambda x: _gettext.gettext(x).decode('UTF-8')\n    ngettext = lambda *x: _gettext.ngettext(*x).decode('UTF-8')\nexcept Exception:\n    _ = _gettext.gettext\n    ngettext = _gettext.ngettext\n", "path": "lib/solaar/i18n.py"}]}