locale: store formats UI label string
This commit is contained in:
@@ -35,7 +35,7 @@ def _configure_variables_set(config):
|
||||
return ('user_name' in config and
|
||||
'user_autologin' in config and
|
||||
'user_password' in config and
|
||||
'formats' in config and
|
||||
'formats_locale' in config and
|
||||
'timezone' in config and
|
||||
'chosen_software_packages' in config)
|
||||
|
||||
@@ -70,7 +70,8 @@ def _set_testing_defaults(config):
|
||||
config["user_name"] = 'user'
|
||||
config["user_autologin"] = True
|
||||
config["user_password"] = 'password'
|
||||
config["formats"] = 'en_US.UTF-8'
|
||||
config["formats_locale"] = 'en_US.UTF-8'
|
||||
config["formats_ui"] = 'United States'
|
||||
config["timezone"] = 'UTC'
|
||||
config["chosen_software_packages"] = ''
|
||||
config["chosen_software"] = []
|
||||
@@ -134,7 +135,7 @@ def create_envs(config, with_install_envs, with_configure_envs):
|
||||
f'OSI_USER_NAME="{config["user_name"]}"',
|
||||
f'OSI_USER_AUTOLOGIN={_bool_to_int(config["user_autologin"])}',
|
||||
f'OSI_USER_PASSWORD="{config["user_password"]}"',
|
||||
f'OSI_FORMATS="{config["formats"]}"',
|
||||
f'OSI_FORMATS="{config["formats_locale"]}"',
|
||||
f'OSI_TIMEZONE="{config["timezone"]}"',
|
||||
f'OSI_ADDITIONAL_SOFTWARE="{config["chosen_software_packages"]}"',
|
||||
]
|
||||
|
||||
@@ -65,16 +65,16 @@ def get_timezone():
|
||||
|
||||
|
||||
def get_current_formats():
|
||||
formats = global_state.get_config('formats')
|
||||
formats = global_state.get_config('formats_locale')
|
||||
if not formats:
|
||||
formats = global_state.get_config('locale')
|
||||
global_state.set_config('formats', formats)
|
||||
global_state.set_config('formats_locale', formats)
|
||||
name = GnomeDesktop.get_country_from_locale(formats)
|
||||
if not name:
|
||||
# solely to prevent crashes, e.g. for Esperanto
|
||||
# TODO add to translatation
|
||||
name = 'Undefined'
|
||||
return (name, formats)
|
||||
return (formats, name)
|
||||
|
||||
|
||||
def get_formats():
|
||||
|
||||
@@ -97,6 +97,10 @@ class LocalePage(Gtk.Stack, Page):
|
||||
|
||||
self.list_stack.set_visible_child_name('timezone_subzones')
|
||||
|
||||
def _set_formats(self, formats_locale, name):
|
||||
set_system_formats(formats_locale, name)
|
||||
self.formats_label.set_label(name)
|
||||
|
||||
def _set_timezone(self, timezone):
|
||||
set_system_timezone(timezone)
|
||||
|
||||
@@ -116,9 +120,7 @@ class LocalePage(Gtk.Stack, Page):
|
||||
|
||||
@Gtk.Template.Callback('formats_selected')
|
||||
def _formats_selected(self, list_box, row):
|
||||
set_system_formats(row.info)
|
||||
|
||||
self.formats_label.set_label(row.get_label())
|
||||
self._set_formats(row.info, row.get_label())
|
||||
self._show_overview()
|
||||
|
||||
@Gtk.Template.Callback('overview_row_activated')
|
||||
@@ -146,9 +148,8 @@ class LocalePage(Gtk.Stack, Page):
|
||||
### public methods ###
|
||||
|
||||
def load_once(self):
|
||||
name, locale = get_current_formats()
|
||||
self.formats_label.set_label(name)
|
||||
global_state.set_config('formats', locale)
|
||||
locale, name = get_current_formats()
|
||||
self._set_formats(locale, name)
|
||||
|
||||
timezone = get_timezone()
|
||||
self.timezone_label.set_label(timezone)
|
||||
|
||||
@@ -73,8 +73,9 @@ def set_system_language(language_info):
|
||||
_exec(['localectl', '--no-ask-password', 'set-locale', 'LANG=en_US.UTF-8'])
|
||||
|
||||
|
||||
def set_system_formats(locale):
|
||||
global_state.set_config('formats', locale)
|
||||
def set_system_formats(locale, formats_label):
|
||||
global_state.set_config('formats_locale', locale)
|
||||
global_state.set_config('formats_ui', formats_label)
|
||||
_exec(['gsettings', 'set', 'org.gnome.system.locale', 'region', f"'{locale}'"])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user