1
0

kivy: locale: set default language based to OS lang

On Android, the default language is now set to the language of the OS,
instead of English.

related https://github.com/spesmilo/electrum/issues/4618
related https://github.com/spesmilo/electrum/issues/7494
This commit is contained in:
SomberNight
2021-09-15 19:51:10 +02:00
parent 22bb52d5df
commit 7cb11ceda4
2 changed files with 12 additions and 2 deletions

View File

@@ -28,6 +28,7 @@ from electrum.bitcoin import COIN
from electrum.gui import messages
from .i18n import _
from .util import get_default_language
from . import KIVY_GUI_PATH
from kivy.app import App
@@ -402,7 +403,7 @@ class ElectrumWindow(App, Logger):
Logger.__init__(self)
self.electrum_config = config = kwargs.get('config', None) # type: SimpleConfig
self.language = config.get('language', 'en')
self.language = config.get('language', get_default_language())
self.network = network = kwargs.get('network', None) # type: Network
if self.network:
self.num_blocks = self.network.get_local_height()

View File

@@ -1,4 +1,4 @@
from kivy.utils import get_color_from_hex
from kivy.utils import get_color_from_hex, platform
def address_colors(wallet, addr):
@@ -21,3 +21,12 @@ def address_colors(wallet, addr):
elif wallet.is_billing_address(addr):
colors = BLUE
return (get_color_from_hex(color) for color in colors)
def get_default_language() -> str:
if platform != 'android':
return 'en_UK'
from jnius import autoclass
Locale = autoclass("java.util.Locale")
lang = str(Locale.getDefault().toString())
return lang if lang else 'en_UK'