Use translator for config translations
This commit is contained in:
@@ -63,7 +63,6 @@ os_installer_sources = [
|
||||
'ui/row/summary_row.py',
|
||||
'ui/terminal_dialog.py',
|
||||
'ui/window.py',
|
||||
'util/config_translation.py',
|
||||
'util/device_info.py',
|
||||
'util/entry_error_enhancer.py',
|
||||
'util/filterable_object.py',
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from enum import Enum
|
||||
from gi.repository import Gio, Gtk
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .choices_provider import choices_provider
|
||||
from .config import config
|
||||
from .config_translation import config_translation
|
||||
from .selection_row import MultiSelectionRow, SelectionRow
|
||||
|
||||
|
||||
@@ -34,18 +32,16 @@ class ChoicesPage(Gtk.Box):
|
||||
exit(0)
|
||||
|
||||
self.model.splice(0, 0, self.list_provider())
|
||||
with config_translation:
|
||||
self.list.bind_model(self.model, self._create_row)
|
||||
self.list.bind_model(self.model, self._create_row)
|
||||
|
||||
def _create_row(self, choice):
|
||||
with config_translation:
|
||||
if choice.options:
|
||||
row = MultiSelectionRow(choice)
|
||||
row.connect("notify::selected-item", self._option_chosen)
|
||||
else:
|
||||
row = SelectionRow(choice)
|
||||
row.connect("activated", self._switch_flipped)
|
||||
return row
|
||||
if choice.options:
|
||||
row = MultiSelectionRow(choice)
|
||||
row.connect("notify::selected-item", self._option_chosen)
|
||||
else:
|
||||
row = SelectionRow(choice)
|
||||
row.connect("activated", self._switch_flipped)
|
||||
return row
|
||||
|
||||
### callbacks ###
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from locale import gettext as _
|
||||
|
||||
from gi.repository import Gdk, GObject, Gtk
|
||||
|
||||
from .config import config
|
||||
from .config_translation import config_translation
|
||||
from .desktop_provider import desktop_provider
|
||||
from .translator import config_gettext as _
|
||||
|
||||
|
||||
@Gtk.Template(resource_path='/com/github/p3732/os-installer/ui/widgets/desktop_entry.ui')
|
||||
@@ -43,14 +41,13 @@ class DesktopPage(Gtk.Box):
|
||||
self.selected_entry = None
|
||||
|
||||
number = 0
|
||||
with config_translation:
|
||||
for desktop in desktop_provider.get_desktops():
|
||||
entry = DesktopEntry(desktop)
|
||||
entry.connect('clicked', self._desktop_activated)
|
||||
if number == 0:
|
||||
self._set_selected_desktop(entry)
|
||||
self.grid.attach(entry, number % 3, int(number/3), 1, 1)
|
||||
number += 1
|
||||
for desktop in desktop_provider.get_desktops():
|
||||
entry = DesktopEntry(desktop)
|
||||
entry.connect('clicked', self._desktop_activated)
|
||||
if number == 0:
|
||||
self._set_selected_desktop(entry)
|
||||
self.grid.attach(entry, number % 3, int(number/3), 1, 1)
|
||||
number += 1
|
||||
|
||||
def _set_selected_desktop(self, entry):
|
||||
desktop = entry.desktop
|
||||
@@ -58,8 +55,7 @@ class DesktopPage(Gtk.Box):
|
||||
self.selected_image.set_paintable(None)
|
||||
self.selected_image.set_paintable(desktop.texture)
|
||||
|
||||
with config_translation:
|
||||
description = _(desktop.description)
|
||||
description = _(desktop.description)
|
||||
self.selected_description.set_label(description)
|
||||
|
||||
if self.selected_entry:
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from locale import gettext as _
|
||||
from pathlib import Path
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .config import config
|
||||
from .config_translation import config_translation
|
||||
from .translator import config_gettext as _
|
||||
from .welcome_provider import welcome_provider
|
||||
|
||||
|
||||
@@ -25,8 +22,7 @@ class WelcomePage(Gtk.Box):
|
||||
welcome = config.get('welcome_page')
|
||||
|
||||
if text := welcome.get('text', None):
|
||||
with config_translation:
|
||||
text = _(text)
|
||||
text = _(text)
|
||||
else:
|
||||
text = self.description.get_label()
|
||||
text = text.format(config.get('distribution_name'))
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from locale import gettext as _
|
||||
|
||||
from gi.repository import Adw, Gtk
|
||||
|
||||
from .translator import config_gettext as _
|
||||
|
||||
|
||||
@Gtk.Template(resource_path='/com/github/p3732/os-installer/ui/row/multi_selection_row.ui')
|
||||
class MultiSelectionRow(Adw.ComboRow):
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from locale import textdomain
|
||||
|
||||
|
||||
class ConfigTranslation():
|
||||
def __enter__(self):
|
||||
textdomain('os-installer-config')
|
||||
return self
|
||||
|
||||
def __exit__(self, exception_type, exception_value, exception_traceback):
|
||||
textdomain('os-installer')
|
||||
|
||||
|
||||
config_translation = ConfigTranslation()
|
||||
Reference in New Issue
Block a user