Skip to content

Commit

Permalink
fixed translation in preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
Nokse22 committed Sep 29, 2024
1 parent d669edf commit 831ab47
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@
from gi.repository import Gtk, Gio, Adw, GLib
from .window import TeleprompterWindow

from gettext import gettext as _
import gettext

from os import path

LOCALE_DIR = path.join(
path.dirname(__file__).split('teleprompter')[0], 'locale')
gettext.bindtextdomain('teleprompter', LOCALE_DIR)
gettext.textdomain('teleprompter')


class TeleprompterApplication(Adw.Application):
"""The main application singleton class."""

def __init__(self):
super().__init__(application_id='io.github.nokse22.teleprompter',
def __init_gettext(self):
super().__init_gettext(application_id='io.github.nokse22.teleprompter',
flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
self.create_action(
'quit', lambda *_: self.quit(), ['<primary>q'])
Expand Down Expand Up @@ -95,7 +102,7 @@ def on_about_action(self, *args):
website='https://github.com/Nokse22/teleprompter',
copyright='© 2023 Noske')
# Replace "translator-credits" with your name/username, and optionally an email or URL.
about.set_translator_credits(_("translator-credits"))
about.set_translator_credits(gettext("translator-credits"))
about.present(self.props.active_window)

def on_preferences_action(self, *args):
Expand All @@ -104,46 +111,46 @@ def on_preferences_action(self, *args):
pref = Adw.PreferencesDialog()

settingsPage = Adw.PreferencesPage(
title=_("Generals"))
title=gettext("Generals"))
settingsPage.set_icon_name("applications-system-symbolic")
pref.add(settingsPage)

scrollSettingsGroup = Adw.PreferencesGroup(
title=_("Scroll Settings"))
title=gettext("Scroll Settings"))
settingsPage.add(scrollSettingsGroup)

scrollSpeedRow = Adw.SpinRow(
title=_("Scroll Speed"),
subtitle=_("In words per minute (approximately)"))
title=gettext("Scroll Speed"),
subtitle=gettext("In words per minute (approximately)"))
scrollSettingsGroup.add(scrollSpeedRow)

speed_adj = Gtk.Adjustment(upper=200, step_increment=1, lower=10)
speed_adj.set_value(self.win.settings.speed)
scrollSpeedRow.set_adjustment(speed_adj)

textGroup = Adw.PreferencesGroup(title=_("Text"))
textGroup = Adw.PreferencesGroup(title=gettext("Text"))
settingsPage.add(textGroup)

highlightColorPickerRow = Adw.ActionRow(
title=_("Highlight color"))
title=gettext("Highlight color"))
textGroup.add(highlightColorPickerRow)

highlightColorPicker = Gtk.ColorButton(valign=Gtk.Align.CENTER)
highlightColorPicker.set_rgba(self.win.settings.highlightColor)
highlightColorPickerRow.add_suffix(highlightColorPicker)

boldHighlight = Adw.ActionRow(title=_("Bold Highlight"))
boldHighlight = Adw.ActionRow(title=gettext("Bold Highlight"))
textGroup.add(boldHighlight)

boldHighlightSwitch = Gtk.Switch(valign=Gtk.Align.CENTER)
boldHighlightSwitch.set_active(self.win.settings.boldHighlight)

boldHighlight.add_suffix(boldHighlightSwitch)

fontColorPickerRow = Adw.ActionRow(title=_("Font color"))
fontColorPickerRow = Adw.ActionRow(title=gettext("Font color"))
textGroup.add(fontColorPickerRow)

fontPickerRow = Adw.ActionRow(title=_("Font"))
fontPickerRow = Adw.ActionRow(title=gettext("Font"))
textGroup.add(fontPickerRow)

fontPicker = Gtk.FontButton(valign=Gtk.Align.CENTER)
Expand Down

0 comments on commit 831ab47

Please sign in to comment.