Browse Source

kivy: settings: better handling of "default" language

patch-4
SomberNight 3 years ago
parent
commit
4293d6eca0
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 15
      electrum/gui/kivy/uix/dialogs/settings.py
  2. 1
      electrum/i18n.py

15
electrum/gui/kivy/uix/dialogs/settings.py

@ -1,3 +1,5 @@
from typing import TYPE_CHECKING
from kivy.app import App
from kivy.factory import Factory
from kivy.properties import ObjectProperty
@ -14,6 +16,10 @@ from electrum.gui.kivy import KIVY_GUI_PATH
from .choice_dialog import ChoiceDialog
if TYPE_CHECKING:
from ...main_window import ElectrumWindow
Builder.load_string('''
#:import partial functools.partial
#:import _ electrum.gui.kivy.i18n._
@ -110,7 +116,7 @@ Builder.load_string('''
class SettingsDialog(Factory.Popup):
def __init__(self, app):
def __init__(self, app: 'ElectrumWindow'):
self.app = app
self.plugins = self.app.plugins
self.config = self.app.electrum_config
@ -132,8 +138,9 @@ class SettingsDialog(Factory.Popup):
self.has_pin_code = self.app.has_pin_code()
self.enable_toggle_use_recoverable_channels = bool(self.wallet.lnworker and self.wallet.lnworker.has_deterministic_node_id())
def get_language_name(self):
return languages.get(self.config.get('language', 'en_UK'), '')
def get_language_name(self) -> str:
lang = self.config.get('language') or ''
return languages.get(lang) or languages.get('') or ''
def change_password(self, dt):
self.app.change_password(self.update)
@ -143,7 +150,7 @@ class SettingsDialog(Factory.Popup):
def language_dialog(self, item, dt):
if self._language_dialog is None:
l = self.config.get('language', 'en_UK')
l = self.config.get('language') or ''
def cb(key):
self.config.set_key("language", key, True)
item.lang = self.get_language_name()

1
electrum/i18n.py

@ -84,3 +84,4 @@ languages = {
'zh_CN': _('Chinese Simplified'),
'zh_TW': _('Chinese Traditional')
}
assert '' in languages

Loading…
Cancel
Save