Skip to content

Commit

Permalink
[GUI][Fixed] Nasty dialog when the locale isn't installed
Browse files Browse the repository at this point in the history
  • Loading branch information
set-soft committed Oct 2, 2024
1 parent f4fc5ee commit 4da5327
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
22 changes: 14 additions & 8 deletions kibot/GUI/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ..config_reader import get_doc_lines
from ..gs import GS
from ..kiplot import config_output, load_board, load_sch, load_config, reset_config, generate_outputs
from ..misc import BASE_HELP
from ..misc import BASE_HELP, W_LANGNOTA
from ..pre_base import BasePreFlight
from ..registrable import RegOutput, Group, GroupEntry, RegFilter, RegVariant
from .data_types import edit_dict, create_new_optionable
Expand Down Expand Up @@ -58,14 +58,20 @@
# Add ../locale as a place to look for catalogs
wx.Locale.AddCatalogLookupPathPrefix(os.path.join(os.path.dirname(__file__), '..', 'locale'))
# Select the language
lang = os.environ.get('LANG', 'en')[:2]
lang = os.environ.get('LANG', 'C')[:2]
from .gui_config import lang_domain, sup_lang
locale = wx.Locale(sup_lang.get(lang, wx.LANGUAGE_SPANISH))
# Add KiBot domain
if locale.IsOk():
locale.AddCatalog(lang_domain)
else:
locale = None
selected_language = sup_lang.get(lang, wx.LANGUAGE_DEFAULT)
# Avoid a nasty dialog (GUI people!!!) by asking if available
if wx.Locale.IsAvailable(selected_language):
locale = wx.Locale(selected_language)
# Add KiBot domain
if locale.IsOk():
locale.AddCatalog(lang_domain)
else:
locale = None
elif lang != 'C':
name = wx.Locale.GetLanguageName(selected_language)
logger.warning(W_LANGNOTA+f'Error setting the current locale ({lang}: {name}), please install it')
# ################################################

OK_CHAR = '\U00002714'
Expand Down
1 change: 1 addition & 0 deletions kibot/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
W_ONMAC = '(W163) '
W_MULTIREF = '(W164) '
W_NOTHREPE = '(W165) '
W_LANGNOTA = '(W166) '
# Somehow arbitrary, the colors are real, but can be different
PCB_MAT_COLORS = {'fr1': "937042", 'fr2': "949d70", 'fr3': "adacb4", 'fr4': "332B16", 'fr5': "6cc290"}
PCB_FINISH_COLORS = {'hal': "8b898c", 'hasl': "8b898c", 'imag': "8b898c", 'enig': "cfb96e", 'enepig': "cfb96e",
Expand Down

0 comments on commit 4da5327

Please sign in to comment.