Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion linux/keyman-config/keyman_config/downloadkeyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import os
import urllib.parse
from keyman_config.keyman_locales import find_locales

import gi

Expand Down Expand Up @@ -30,7 +31,7 @@ def __init__(self, parent=None):
self.webview = WebKit2.WebView()
self.webview.connect("decide-policy", self._keyman_policy)
self.webview.connect("load-changed", self._update_back_button)
url = KeymanComUrl + "/go/linux/" + __releaseversion__ + "/download-keyboards"
url = KeymanComUrl + "/go/linux/" + __releaseversion__ + "/download-keyboards" + "?lang=" + self._get_current_locale()
self.webview.load_uri(url)
s.add(self.webview)

Expand All @@ -56,6 +57,12 @@ def __init__(self, parent=None):
self.resize(800, 450)
self.show_all()

def _get_current_locale(self):
loc = find_locales()[0]
if loc == "C":
loc = "en"
return loc.replace('_','-')

def _update_back_button(self, webview, load_event):
self.back_button.set_sensitive(webview.can_go_back())

Expand Down
30 changes: 30 additions & 0 deletions linux/keyman-config/keyman_config/keyman_locales.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/python3
#
# Keyman is copyright (C) SIL Global. MIT License.
#
# Created by Marc Durdin on 2026-08-18
#
# Find the current display locale ID, using the same method as
# gettext.find()
#

import os

#
# @returns array of language identifiers in POSIX style, i.e. 'en_US', not 'en-US'.
#
# The returned array always includes the value 'C' for the default static locale,
# which should be replaced with 'en' when passed to other processes
#
def find_locales():
# Approach comes from gettext.find()
languages = []
for envvar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
val = os.environ.get(envvar)
if val:
languages = val.split(':')
break
if 'C' not in languages:
languages.append('C')

return languages