From 69f5d07ff938bcb91cefdc91d4496ea6f162cf34 Mon Sep 17 00:00:00 2001 From: Nico Alt <nicoalt@posteo.org> Date: Fri, 2 Oct 2020 10:45:47 +0200 Subject: [PATCH] Revert pgettext workaround and remove source context This doesn't work, because gettext doesn't pick up the translations. The context in the source string makes gettext think that it's a special translation, while our workaround suggests that it has no context. Transifex offers the option to add context manually. --- briar-gtk/briar_gtk/containers/main_window.py | 5 ++--- briar-gtk/briar_gtk/utils.py | 13 ------------- briar-gtk/briar_gtk/widgets/about_dialog.py | 15 +++++++++------ briar-gtk/briar_gtk/widgets/private_message.py | 10 +++++----- 4 files changed, 16 insertions(+), 27 deletions(-) delete mode 100644 briar-gtk/briar_gtk/utils.py diff --git a/briar-gtk/briar_gtk/containers/main_window.py b/briar-gtk/briar_gtk/containers/main_window.py index d8e4f1f..6ce8226 100644 --- a/briar-gtk/briar_gtk/containers/main_window.py +++ b/briar-gtk/briar_gtk/containers/main_window.py @@ -14,7 +14,6 @@ from briar_gtk.container import Container from briar_gtk.containers.private_chat import PrivateChatContainer from briar_gtk.define import APP, NOTIFICATION_CONTACT_ADDED from briar_gtk.define import NOTIFICATION_PRIVATE_MESSAGE -from briar_gtk.utils import pgettext as _t from briar_gtk.widgets.about_dialog import AboutDialogWidget from briar_gtk.widgets.contact_row import ContactRowWidget @@ -262,14 +261,14 @@ class MainWindowContainer(Container): # pylint: disable=unused-argument def _notify_contact_added(self, message): self._notify( - _t("Notification", "Contact added"), + _("Contact added"), # context: "Notification" NOTIFICATION_CONTACT_ADDED ) # pylint: disable=unused-argument def _notify_message_received(self, message): self._notify( - _t("Notification", "New private message"), + _("New private message"), # context: "Notification" NOTIFICATION_PRIVATE_MESSAGE ) diff --git a/briar-gtk/briar_gtk/utils.py b/briar-gtk/briar_gtk/utils.py deleted file mode 100644 index 634beb1..0000000 --- a/briar-gtk/briar_gtk/utils.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2020 Nico Alt -# SPDX-License-Identifier: AGPL-3.0-only -# License-Filename: LICENSE.md - -import gettext - - -# pylint: disable=unused-argument -def pgettext(context, message): - """ - Backport of `gettext.pgettext` which is only available in Python 3.8+ - """ - return gettext.gettext(message) diff --git a/briar-gtk/briar_gtk/widgets/about_dialog.py b/briar-gtk/briar_gtk/widgets/about_dialog.py index b03ffff..aea1b20 100644 --- a/briar-gtk/briar_gtk/widgets/about_dialog.py +++ b/briar-gtk/briar_gtk/widgets/about_dialog.py @@ -4,10 +4,10 @@ import os +from gettext import gettext as _ from gi.repository import Gtk from briar_gtk.define import APP, RESOURCES_DIR -from briar_gtk.utils import pgettext as _t class AboutDialogWidget(): @@ -33,8 +33,10 @@ class AboutDialogWidget(): self._about_dialog.connect("response", self._on_about_response) def _add_code_section(self): - code_use_title = _t( - "Used in about dialog to credit other programs like GNOME Fractal", + code_use_title = _( + # Context: + # "Used in about dialog to credit " + # "other programs like GNOME Fractal" "Using code by" ) code_use_list = [ @@ -47,9 +49,10 @@ class AboutDialogWidget(): # pylint: disable=line-too-long def _add_briar_section(self): - briar_functionality_title = _t( - "Used in about dialog to credit " - "Briar components like its REST API", + briar_functionality_title = _( + # Context: + # "Used in about dialog to credit Briar " + # "components like its REST API" "Briar functionality by" ) briar_functionality_list = [ diff --git a/briar-gtk/briar_gtk/widgets/private_message.py b/briar-gtk/briar_gtk/widgets/private_message.py index 878428c..b26e553 100644 --- a/briar-gtk/briar_gtk/widgets/private_message.py +++ b/briar-gtk/briar_gtk/widgets/private_message.py @@ -7,10 +7,9 @@ from datetime import datetime +from gettext import gettext as _ from gi.repository import Gtk -from briar_gtk.utils import pgettext as _t - class PrivateMessageWidget(Gtk.ListBoxRow): @@ -24,9 +23,10 @@ class PrivateMessageWidget(Gtk.ListBoxRow): username = contact_name username_style_class = "username" if message["local"]: - username = _t( - "Used in message history to indicate that message is" - "by the user itself, not by its contact", + username = _( + # Context: + # "Used in message history to indicate that message is" + # "by the user itself, not by its contact" "Myself" ) username_style_class = "username-self" -- GitLab