Replace transalate() by gettext()
gettext() is picked up by localization tooling.
This commit is contained in:
parent
63c9279fa8
commit
7940f987f3
@ -6,6 +6,6 @@ An average module should only need to import this module.
|
||||
|
||||
from gaphor.action import action, primary
|
||||
from gaphor.application import Application
|
||||
from gaphor.i18n import translate
|
||||
from gaphor.i18n import gettext
|
||||
from gaphor.services.eventmanager import event_handler
|
||||
from gaphor.transaction import Transaction, transactional
|
||||
|
@ -3,7 +3,7 @@ import math
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.core import transactional, translate
|
||||
from gaphor.core import gettext, transactional
|
||||
from gaphor.diagram.actions import ForkNodeItem, ObjectNodeItem
|
||||
from gaphor.diagram.propertypages import (
|
||||
NamedElementPropertyPage,
|
||||
@ -30,7 +30,7 @@ class ObjectNodePropertyPage(NamedItemPropertyPage):
|
||||
if not subject:
|
||||
return page
|
||||
|
||||
hbox = create_hbox_label(self, page, translate("Upper bound"))
|
||||
hbox = create_hbox_label(self, page, gettext("Upper bound"))
|
||||
entry = Gtk.Entry()
|
||||
entry.set_text(subject.upperBound or "")
|
||||
entry.connect("changed", self._on_upper_bound_change)
|
||||
@ -45,7 +45,7 @@ class ObjectNodePropertyPage(NamedItemPropertyPage):
|
||||
hbox.pack_start(combo, False, True, 0)
|
||||
|
||||
hbox = create_hbox_label(self, page, "")
|
||||
button = Gtk.CheckButton(translate("Ordering"))
|
||||
button = Gtk.CheckButton(gettext("Ordering"))
|
||||
button.set_active(self.item.show_ordering)
|
||||
button.connect("toggled", self._on_ordering_show_change)
|
||||
hbox.pack_start(button, False, True, 0)
|
||||
@ -86,13 +86,13 @@ class JoinNodePropertyPage(NamedItemPropertyPage):
|
||||
page.pack_start(hbox, False, True, 0)
|
||||
|
||||
if isinstance(subject, UML.JoinNode):
|
||||
hbox = create_hbox_label(self, page, translate("Join specification"))
|
||||
hbox = create_hbox_label(self, page, gettext("Join specification"))
|
||||
entry = Gtk.Entry()
|
||||
entry.set_text(subject.joinSpec or "")
|
||||
entry.connect("changed", self._on_join_spec_change)
|
||||
hbox.pack_start(entry, True, True, 0)
|
||||
|
||||
button = Gtk.CheckButton(translate("Horizontal"))
|
||||
button = Gtk.CheckButton(gettext("Horizontal"))
|
||||
button.set_active(self.item.matrix[2] != 0)
|
||||
button.connect("toggled", self._on_horizontal_change)
|
||||
page.pack_start(button, False, True, 0)
|
||||
@ -129,7 +129,7 @@ class FlowPropertyPageAbstract(NamedElementPropertyPage):
|
||||
if not subject:
|
||||
return page
|
||||
|
||||
hbox = create_hbox_label(self, page, translate("Guard"))
|
||||
hbox = create_hbox_label(self, page, gettext("Guard"))
|
||||
entry = Gtk.Entry()
|
||||
entry.set_text(subject.guard or "")
|
||||
changed_id = entry.connect("changed", self._on_guard_change)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor.core import transactional, translate
|
||||
from gaphor.core import gettext, transactional
|
||||
from gaphor.diagram.actions.partition import PartitionItem
|
||||
from gaphor.diagram.propertypages import NamedItemPropertyPage, PropertyPages
|
||||
|
||||
@ -19,7 +19,7 @@ class PartitionPropertyPage(NamedItemPropertyPage):
|
||||
if item.subject:
|
||||
if not item._toplevel:
|
||||
hbox = Gtk.HBox(spacing=12)
|
||||
button = Gtk.CheckButton(translate("External"))
|
||||
button = Gtk.CheckButton(gettext("External"))
|
||||
button.set_active(item.subject.isExternal)
|
||||
button.connect("toggled", self._on_external_change)
|
||||
hbox.pack_start(button, True, True, 0)
|
||||
|
@ -4,7 +4,7 @@ from gaphas.decorators import AsyncIO
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.core import transactional, translate
|
||||
from gaphor.core import gettext, transactional
|
||||
from gaphor.diagram.classes import (
|
||||
AssociationItem,
|
||||
ClassItem,
|
||||
@ -117,7 +117,7 @@ class ClassPropertyPage(NamedElementPropertyPage):
|
||||
label.set_justify(Gtk.Justification.LEFT)
|
||||
self.size_group.add_widget(label)
|
||||
hbox.pack_start(label, False, True, 0)
|
||||
button = Gtk.CheckButton(label=translate("Abstract"))
|
||||
button = Gtk.CheckButton(label=gettext("Abstract"))
|
||||
button.set_active(self.subject.isAbstract)
|
||||
|
||||
button.connect("toggled", self._on_abstract_change)
|
||||
@ -146,7 +146,7 @@ class InterfacePropertyPage(NamedItemPropertyPage):
|
||||
self.size_group.add_widget(label)
|
||||
hbox.pack_start(label, False, True, 0)
|
||||
|
||||
button = Gtk.CheckButton(translate("Folded"))
|
||||
button = Gtk.CheckButton(gettext("Folded"))
|
||||
button.set_active(item.folded != Folded.NONE)
|
||||
button.connect("toggled", self._on_fold_change)
|
||||
|
||||
@ -196,7 +196,7 @@ class AttributesPage(PropertyPageBase):
|
||||
label = Gtk.Label(label="")
|
||||
label.set_justify(Gtk.Justification.LEFT)
|
||||
hbox.pack_start(label, False, True, 0)
|
||||
button = Gtk.CheckButton(label=translate("Show attributes"))
|
||||
button = Gtk.CheckButton(label=gettext("Show attributes"))
|
||||
button.set_active(self.item.show_attributes)
|
||||
button.connect("toggled", self._on_show_attributes_change)
|
||||
hbox.pack_start(button, True, True, 0)
|
||||
@ -214,7 +214,7 @@ Add and edit class attributes according to UML syntax. Attribute syntax examples
|
||||
- # /attr: int
|
||||
"""
|
||||
tree_view = create_tree_view(
|
||||
self.model, (translate("Attributes"), translate("S")), tip
|
||||
self.model, (gettext("Attributes"), gettext("S")), tip
|
||||
)
|
||||
page.pack_start(tree_view, True, True, 0)
|
||||
|
||||
@ -271,7 +271,7 @@ class OperationsPage(PropertyPageBase):
|
||||
label = Gtk.Label(label="")
|
||||
label.set_justify(Gtk.Justification.LEFT)
|
||||
hbox.pack_start(label, False, True, 0)
|
||||
button = Gtk.CheckButton(label=translate("Show operations"))
|
||||
button = Gtk.CheckButton(label=gettext("Show operations"))
|
||||
button.set_active(self.item.show_operations)
|
||||
button.connect("toggled", self._on_show_operations_change)
|
||||
hbox.pack_start(button, True, True, 0)
|
||||
@ -288,7 +288,7 @@ Add and edit class operations according to UML syntax. Operation syntax examples
|
||||
- # call(a: int: b: str): bool
|
||||
"""
|
||||
tree_view = create_tree_view(
|
||||
self.model, (translate("Operation"), translate("A"), translate("S")), tip
|
||||
self.model, (gettext("Operation"), gettext("A"), gettext("S")), tip
|
||||
)
|
||||
page.pack_start(tree_view, True, True, 0)
|
||||
|
||||
@ -332,10 +332,10 @@ class DependencyPropertyPage(PropertyPageBase):
|
||||
order = 0
|
||||
|
||||
DEPENDENCY_TYPES = (
|
||||
(translate("Dependency"), UML.Dependency),
|
||||
(translate("Usage"), UML.Usage),
|
||||
(translate("Realization"), UML.Realization),
|
||||
(translate("Implementation"), UML.Implementation),
|
||||
(gettext("Dependency"), UML.Dependency),
|
||||
(gettext("Usage"), UML.Usage),
|
||||
(gettext("Realization"), UML.Realization),
|
||||
(gettext("Implementation"), UML.Implementation),
|
||||
)
|
||||
|
||||
def __init__(self, item):
|
||||
@ -347,7 +347,7 @@ class DependencyPropertyPage(PropertyPageBase):
|
||||
def construct(self):
|
||||
page = Gtk.VBox()
|
||||
|
||||
hbox = create_hbox_label(self, page, translate("Dependency type"))
|
||||
hbox = create_hbox_label(self, page, gettext("Dependency type"))
|
||||
|
||||
self.combo = create_uml_combo(
|
||||
self.DEPENDENCY_TYPES, self._on_dependency_type_change
|
||||
@ -356,7 +356,7 @@ class DependencyPropertyPage(PropertyPageBase):
|
||||
|
||||
hbox = create_hbox_label(self, page, "")
|
||||
|
||||
button = Gtk.CheckButton(translate("Automatic"))
|
||||
button = Gtk.CheckButton(gettext("Automatic"))
|
||||
button.set_active(self.item.auto_dependency)
|
||||
button.connect("toggled", self._on_auto_dependency_change)
|
||||
hbox.pack_start(button, True, True, 0)
|
||||
@ -431,7 +431,7 @@ class AssociationPropertyPage(NamedItemPropertyPage):
|
||||
self.size_group.add_widget(label)
|
||||
hbox.pack_start(label, False, True, 0)
|
||||
|
||||
button = Gtk.CheckButton(label=translate("Show direction"))
|
||||
button = Gtk.CheckButton(label=gettext("Show direction"))
|
||||
button.set_active(self.item.show_direction)
|
||||
button.connect("toggled", self._on_show_direction_change)
|
||||
hbox.pack_start(button, True, True, 0)
|
||||
@ -444,11 +444,11 @@ class AssociationPropertyPage(NamedItemPropertyPage):
|
||||
|
||||
page.pack_start(hbox, False, True, 0)
|
||||
|
||||
box = self.construct_end(translate("Head"), self.item.head_end)
|
||||
box = self.construct_end(gettext("Head"), self.item.head_end)
|
||||
if box:
|
||||
page.pack_start(box, False, True, 0)
|
||||
|
||||
box = self.construct_end(translate("Tail"), self.item.tail_end)
|
||||
box = self.construct_end(gettext("Tail"), self.item.tail_end)
|
||||
if box:
|
||||
page.pack_start(box, False, True, 0)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.core import transactional, translate
|
||||
from gaphor.core import gettext, transactional
|
||||
from gaphor.diagram.components import ComponentItem
|
||||
from gaphor.diagram.propertypages import NamedItemPropertyPage, PropertyPages
|
||||
|
||||
@ -24,7 +24,7 @@ class ComponentPropertyPage(NamedItemPropertyPage):
|
||||
hbox = Gtk.HBox()
|
||||
page.pack_start(hbox, False, True, 0)
|
||||
|
||||
button = Gtk.CheckButton(translate("Indirectly instantiated"))
|
||||
button = Gtk.CheckButton(gettext("Indirectly instantiated"))
|
||||
button.set_active(subject.isIndirectlyInstantiated)
|
||||
button.connect("toggled", self._on_ii_change)
|
||||
hbox.pack_start(button, False, True, 0)
|
||||
|
@ -1,7 +1,7 @@
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.core import transactional, translate
|
||||
from gaphor.core import gettext, transactional
|
||||
from gaphor.diagram.propertypages import PropertyPageBase, PropertyPages
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ class CommentItemPropertyPage(PropertyPageBase):
|
||||
if not subject:
|
||||
return page
|
||||
|
||||
label = Gtk.Label(label=translate("Comment"))
|
||||
label = Gtk.Label(label=gettext("Comment"))
|
||||
label.set_justify(Gtk.Justification.LEFT)
|
||||
page.pack_start(label, False, True, 0)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.core import transactional, translate
|
||||
from gaphor.core import gettext, transactional
|
||||
from gaphor.diagram.interactions import MessageItem
|
||||
from gaphor.diagram.propertypages import (
|
||||
EditableTreeModel,
|
||||
@ -21,7 +21,7 @@ class MessagePropertyPage(NamedItemPropertyPage):
|
||||
be added. On sequence diagram sort of message can be changed.
|
||||
"""
|
||||
|
||||
NAME_LABEL = translate("Message")
|
||||
NAME_LABEL = gettext("Message")
|
||||
|
||||
MESSAGE_SORT = [
|
||||
("Call", "synchCall"),
|
||||
@ -42,7 +42,7 @@ class MessagePropertyPage(NamedItemPropertyPage):
|
||||
return page
|
||||
|
||||
if not item.is_communication():
|
||||
hbox = create_hbox_label(self, page, translate("Message sort"))
|
||||
hbox = create_hbox_label(self, page, gettext("Message sort"))
|
||||
|
||||
sort_data = self.MESSAGE_SORT
|
||||
lifeline = None
|
||||
|
@ -5,7 +5,7 @@ Metaclass item editors.
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.core import translate
|
||||
from gaphor.core import gettext
|
||||
from gaphor.diagram.propertypages import (
|
||||
NamedElementPropertyPage,
|
||||
PropertyPages,
|
||||
@ -29,7 +29,7 @@ class MetaclassNamePropertyPage(NamedElementPropertyPage):
|
||||
|
||||
order = 10
|
||||
|
||||
NAME_LABEL = translate("Name")
|
||||
NAME_LABEL = gettext("Name")
|
||||
|
||||
CLASSES = list(
|
||||
sorted(
|
||||
|
@ -5,7 +5,7 @@ Stereotype property page.
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.core import transactional, translate
|
||||
from gaphor.core import gettext, transactional
|
||||
from gaphor.diagram.propertypages import PropertyPageBase, PropertyPages
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ def create_stereotype_tree_view(model, toggle_stereotype, set_slot_value):
|
||||
|
||||
# Stereotype/Attributes
|
||||
col = Gtk.TreeViewColumn.new()
|
||||
col.set_title("{} / {}".format(translate("Stereotype"), translate("Attribute")))
|
||||
col.set_title("{} / {}".format(gettext("Stereotype"), gettext("Attribute")))
|
||||
col.set_expand(True)
|
||||
renderer = Gtk.CellRendererToggle()
|
||||
renderer.set_property("active", True)
|
||||
@ -51,7 +51,7 @@ def create_stereotype_tree_view(model, toggle_stereotype, set_slot_value):
|
||||
renderer = Gtk.CellRendererText()
|
||||
renderer.set_property("is-expanded", True)
|
||||
renderer.connect("edited", set_slot_value, model, 1)
|
||||
col = Gtk.TreeViewColumn(translate("Value"), renderer, text=1)
|
||||
col = Gtk.TreeViewColumn(gettext("Value"), renderer, text=1)
|
||||
col.set_expand(True)
|
||||
|
||||
def set_editable(column, cell, model, iter, data):
|
||||
@ -92,7 +92,7 @@ class StereotypePage(PropertyPageBase):
|
||||
hbox = Gtk.HBox()
|
||||
label = Gtk.Label(label="")
|
||||
hbox.pack_start(label, False, True, 0)
|
||||
button = Gtk.CheckButton(label=translate("Show stereotypes attributes"))
|
||||
button = Gtk.CheckButton(label=gettext("Show stereotypes attributes"))
|
||||
button.set_active(self.item.show_stereotypes)
|
||||
button.connect("toggled", self._on_show_stereotypes_change)
|
||||
hbox.pack_start(button, True, True, 0)
|
||||
|
@ -33,7 +33,7 @@ from gaphas.segment import Segment
|
||||
from gi.repository import Gdk, GObject, Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.core import transactional, translate
|
||||
from gaphor.core import gettext, transactional
|
||||
|
||||
|
||||
class _PropertyPages:
|
||||
@ -388,7 +388,7 @@ class NamedElementPropertyPage(PropertyPageBase):
|
||||
|
||||
order = 10
|
||||
|
||||
NAME_LABEL = translate("Name")
|
||||
NAME_LABEL = gettext("Name")
|
||||
|
||||
def __init__(self, subject: UML.NamedElement):
|
||||
assert subject is None or isinstance(subject, UML.NamedElement), "%s" % type(
|
||||
@ -462,7 +462,7 @@ class LineStylePage(PropertyPageBase):
|
||||
self.size_group.add_widget(label)
|
||||
hbox.pack_start(label, False, True, 0)
|
||||
|
||||
button = Gtk.CheckButton(label=translate("Orthogonal"))
|
||||
button = Gtk.CheckButton(label=gettext("Orthogonal"))
|
||||
button.set_active(self.item.orthogonal)
|
||||
button.connect("toggled", self._on_orthogonal_change)
|
||||
hbox.pack_start(button, True, True, 0)
|
||||
@ -475,7 +475,7 @@ class LineStylePage(PropertyPageBase):
|
||||
self.size_group.add_widget(label)
|
||||
hbox.pack_start(label, False, True, 0)
|
||||
|
||||
button = Gtk.CheckButton(label=translate("Horizontal"))
|
||||
button = Gtk.CheckButton(label=gettext("Horizontal"))
|
||||
button.set_active(self.item.horizontal)
|
||||
button.connect("toggled", self._on_horizontal_change)
|
||||
hbox.pack_start(button, True, True, 0)
|
||||
|
@ -7,7 +7,7 @@ gaphor.adapter package.
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.core import transactional, translate
|
||||
from gaphor.core import gettext, transactional
|
||||
from gaphor.diagram.propertypages import (
|
||||
NamedItemPropertyPage,
|
||||
PropertyPages,
|
||||
@ -31,7 +31,7 @@ class TransitionPropertyPage(NamedItemPropertyPage):
|
||||
if not subject:
|
||||
return page
|
||||
|
||||
hbox = create_hbox_label(self, page, translate("Guard"))
|
||||
hbox = create_hbox_label(self, page, gettext("Guard"))
|
||||
entry = Gtk.Entry()
|
||||
v = subject.guard.specification
|
||||
entry.set_text(v if v else "")
|
||||
@ -69,21 +69,21 @@ class StatePropertyPage(NamedItemPropertyPage):
|
||||
if not subject:
|
||||
return page
|
||||
|
||||
hbox = create_hbox_label(self, page, translate("Entry"))
|
||||
hbox = create_hbox_label(self, page, gettext("Entry"))
|
||||
entry = Gtk.Entry()
|
||||
if subject.entry:
|
||||
entry.set_text(subject.entry.name or "")
|
||||
entry.connect("changed", self.on_text_change, self.set_entry)
|
||||
hbox.pack_start(entry, True, True, 0)
|
||||
|
||||
hbox = create_hbox_label(self, page, translate("Exit"))
|
||||
hbox = create_hbox_label(self, page, gettext("Exit"))
|
||||
entry = Gtk.Entry()
|
||||
if subject.exit:
|
||||
entry.set_text(subject.exit.name or "")
|
||||
entry.connect("changed", self.on_text_change, self.set_exit)
|
||||
hbox.pack_start(entry, True, True, 0)
|
||||
|
||||
hbox = create_hbox_label(self, page, translate("Do Activity"))
|
||||
hbox = create_hbox_label(self, page, gettext("Do Activity"))
|
||||
entry = Gtk.Entry()
|
||||
if subject.doActivity:
|
||||
entry.set_text(self.subject.doActivity.name or "")
|
||||
|
@ -1,11 +1,11 @@
|
||||
"""Internationalization (i18n) support for Gaphor.
|
||||
|
||||
Translate text in to your native language using the translate() function.
|
||||
Translate text in to your native language using the gettext() function.
|
||||
|
||||
"""
|
||||
__all__ = ["translate"]
|
||||
__all__ = ["gettext"]
|
||||
|
||||
import gettext
|
||||
import gettext as _gettext
|
||||
import os
|
||||
|
||||
import importlib_metadata
|
||||
@ -16,10 +16,10 @@ localedir = os.path.join(
|
||||
|
||||
try:
|
||||
|
||||
catalog = gettext.Catalog("gaphor", localedir=localedir)
|
||||
translate = catalog.gettext
|
||||
catalog = _gettext.Catalog("gaphor", localedir=localedir)
|
||||
gettext = catalog.gettext
|
||||
|
||||
except OSError:
|
||||
|
||||
def translate(s):
|
||||
def gettext(s):
|
||||
return s
|
||||
|
@ -10,7 +10,7 @@ import sys
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor.i18n import translate
|
||||
from gaphor.i18n import gettext
|
||||
|
||||
|
||||
def error_handler(message=None, exc_info=None):
|
||||
@ -20,14 +20,14 @@ def error_handler(message=None, exc_info=None):
|
||||
return
|
||||
|
||||
if not message:
|
||||
message = translate("An error occurred.")
|
||||
message = gettext("An error occurred.")
|
||||
|
||||
buttons = Gtk.ButtonsType.OK
|
||||
message = f"{message}\n\nTechnical details:\n\t{exc_type}\n\t{exc_value}"
|
||||
|
||||
if __debug__ and sys.stdin.isatty():
|
||||
buttons = Gtk.ButtonsType.YES_NO
|
||||
message += translate(
|
||||
message += gettext(
|
||||
"\n\nDo you want to debug?\n(Gaphor should have been started from the command line)"
|
||||
)
|
||||
|
||||
|
@ -9,7 +9,7 @@ from gaphas.painter import BoundingBoxPainter, ItemPainter
|
||||
from gaphas.view import Context, View
|
||||
|
||||
from gaphor.abc import ActionProvider, Service
|
||||
from gaphor.core import action, translate
|
||||
from gaphor.core import action, gettext
|
||||
from gaphor.ui.filedialog import FileDialog
|
||||
from gaphor.ui.questiondialog import QuestionDialog
|
||||
|
||||
@ -44,7 +44,7 @@ class DiagramExport(Service, ActionProvider):
|
||||
filename = file_dialog.selection
|
||||
if os.path.exists(filename):
|
||||
question = (
|
||||
translate(
|
||||
gettext(
|
||||
"The file %s already exists. Do you want to "
|
||||
"replace it with the file you are exporting "
|
||||
"to?"
|
||||
@ -119,11 +119,11 @@ class DiagramExport(Service, ActionProvider):
|
||||
|
||||
@action(
|
||||
name="file-export-svg",
|
||||
label=translate("Export to SVG"),
|
||||
tooltip=translate("Export the diagram to SVG"),
|
||||
label=gettext("Export to SVG"),
|
||||
tooltip=gettext("Export the diagram to SVG"),
|
||||
)
|
||||
def save_svg_action(self):
|
||||
title = translate("Export diagram to SVG")
|
||||
title = gettext("Export diagram to SVG")
|
||||
ext = ".svg"
|
||||
diagram = self.diagrams.get_current_diagram()
|
||||
filename = self.save_dialog(diagram, title, ext)
|
||||
@ -132,11 +132,11 @@ class DiagramExport(Service, ActionProvider):
|
||||
|
||||
@action(
|
||||
name="file-export-png",
|
||||
label=translate("Export to PNG"),
|
||||
tooltip=translate("Export the diagram to PNG"),
|
||||
label=gettext("Export to PNG"),
|
||||
tooltip=gettext("Export the diagram to PNG"),
|
||||
)
|
||||
def save_png_action(self):
|
||||
title = translate("Export diagram to PNG")
|
||||
title = gettext("Export diagram to PNG")
|
||||
ext = ".png"
|
||||
diagram = self.diagrams.get_current_diagram()
|
||||
filename = self.save_dialog(diagram, title, ext)
|
||||
@ -145,11 +145,11 @@ class DiagramExport(Service, ActionProvider):
|
||||
|
||||
@action(
|
||||
name="file-export-pdf",
|
||||
label=translate("Export to PDF"),
|
||||
tooltip=translate("Export the diagram to PDF"),
|
||||
label=gettext("Export to PDF"),
|
||||
tooltip=gettext("Export the diagram to PDF"),
|
||||
)
|
||||
def save_pdf_action(self):
|
||||
title = translate("Export diagram to PDF")
|
||||
title = gettext("Export diagram to PDF")
|
||||
ext = ".pdf"
|
||||
diagram = self.diagrams.get_current_diagram()
|
||||
filename = self.save_dialog(diagram, title, ext)
|
||||
|
@ -5,7 +5,7 @@ This plugin extends Gaphor with XMI export functionality.
|
||||
import logging
|
||||
|
||||
from gaphor.abc import ActionProvider, Service
|
||||
from gaphor.core import action, translate
|
||||
from gaphor.core import action, gettext
|
||||
from gaphor.plugins.xmiexport import exportmodel
|
||||
from gaphor.ui.filedialog import FileDialog
|
||||
|
||||
@ -23,8 +23,8 @@ class XMIExport(Service, ActionProvider):
|
||||
|
||||
@action(
|
||||
name="file-export-xmi",
|
||||
label=translate("Export to XMI"),
|
||||
tooltip=translate("Export model to XMI (XML Model Interchange) format"),
|
||||
label=gettext("Export to XMI"),
|
||||
tooltip=gettext("Export model to XMI (XML Model Interchange) format"),
|
||||
)
|
||||
def execute(self):
|
||||
filename = self.file_manager.filename
|
||||
@ -34,7 +34,7 @@ class XMIExport(Service, ActionProvider):
|
||||
filename = "model.xmi"
|
||||
|
||||
file_dialog = FileDialog(
|
||||
translate("Export model to XMI file"), action="save", filename=filename
|
||||
gettext("Export model to XMI file"), action="save", filename=filename
|
||||
)
|
||||
|
||||
filename = file_dialog.selection
|
||||
|
@ -7,7 +7,7 @@ from typing import Dict, Set
|
||||
import gaphas
|
||||
|
||||
from gaphor.abc import ActionProvider, Service
|
||||
from gaphor.core import action, event_handler, transactional, translate
|
||||
from gaphor.core import action, event_handler, gettext, transactional
|
||||
from gaphor.ui.event import DiagramSelectionChanged
|
||||
from gaphor.UML import Element, Presentation
|
||||
from gaphor.UML.collection import collection
|
||||
@ -125,7 +125,7 @@ class CopyService(Service, ActionProvider):
|
||||
|
||||
@action(
|
||||
name="edit-copy",
|
||||
label=translate("Copy"),
|
||||
label=gettext("Copy"),
|
||||
icon_name="edit-copy",
|
||||
shortcut="<Primary>c",
|
||||
)
|
||||
|
@ -18,7 +18,7 @@ from gaphas import state
|
||||
|
||||
from gaphor.abc import ActionProvider, Service
|
||||
from gaphor.action import action
|
||||
from gaphor.core import event_handler, translate
|
||||
from gaphor.core import event_handler, gettext
|
||||
from gaphor.event import (
|
||||
ActionEnabled,
|
||||
ServiceEvent,
|
||||
@ -189,7 +189,7 @@ class UndoManager(Service, ActionProvider):
|
||||
|
||||
@action(
|
||||
name="edit-undo",
|
||||
label=translate("_Undo"),
|
||||
label=gettext("_Undo"),
|
||||
icon_name="edit-undo",
|
||||
shortcut="<Primary>z",
|
||||
)
|
||||
@ -224,7 +224,7 @@ class UndoManager(Service, ActionProvider):
|
||||
|
||||
@action(
|
||||
name="edit-redo",
|
||||
label=translate("_Redo"),
|
||||
label=gettext("_Redo"),
|
||||
icon_name="edit-redo",
|
||||
shortcut="<Primary><Shift>z",
|
||||
)
|
||||
|
@ -20,7 +20,7 @@ import gaphas
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.application import Application
|
||||
from gaphor.i18n import translate
|
||||
from gaphor.i18n import gettext
|
||||
from gaphor.storage import diagramitems, parser
|
||||
from gaphor.UML.collection import collection
|
||||
|
||||
@ -176,7 +176,7 @@ def load_elements_generator(elements, factory, gaphor_version): # noqa: C901
|
||||
Load a file and create a model if possible.
|
||||
Exceptions: IOError, ValueError.
|
||||
"""
|
||||
log.debug(translate("Loading %d elements...") % len(elements))
|
||||
log.debug(gettext("Loading %d elements...") % len(elements))
|
||||
|
||||
# The elements are iterated three times:
|
||||
size = len(elements) * 3
|
||||
|
@ -15,7 +15,7 @@ from gaphas.view import GtkView
|
||||
from gi.repository import Gdk, GLib, Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.core import action, event_handler, transactional, translate
|
||||
from gaphor.core import action, event_handler, gettext, transactional
|
||||
from gaphor.diagram.support import get_diagram_item
|
||||
from gaphor.services.properties import PropertyChanged
|
||||
from gaphor.transaction import Transaction
|
||||
@ -53,7 +53,7 @@ class DiagramPage:
|
||||
self.event_manager.subscribe(self._on_sloppy_lines)
|
||||
self.event_manager.subscribe(self._on_diagram_item_created)
|
||||
|
||||
title = property(lambda s: s.diagram and s.diagram.name or translate("<None>"))
|
||||
title = property(lambda s: s.diagram and s.diagram.name or gettext("<None>"))
|
||||
|
||||
def get_diagram(self):
|
||||
return self.diagram
|
||||
@ -153,7 +153,7 @@ class DiagramPage:
|
||||
|
||||
@action(
|
||||
name="diagram.zoom-in",
|
||||
label=translate("Zoom _In"),
|
||||
label=gettext("Zoom _In"),
|
||||
icon_name="zoom-in",
|
||||
shortcut="<Primary>plus",
|
||||
)
|
||||
@ -163,7 +163,7 @@ class DiagramPage:
|
||||
|
||||
@action(
|
||||
name="diagram.zoom-out",
|
||||
label=translate("Zoom _Out"),
|
||||
label=gettext("Zoom _Out"),
|
||||
icon_name="zoom-out",
|
||||
shortcut="<Primary>minus",
|
||||
)
|
||||
@ -173,7 +173,7 @@ class DiagramPage:
|
||||
|
||||
@action(
|
||||
name="diagram.zoom-100",
|
||||
label=translate("_Normal Size"),
|
||||
label=gettext("_Normal Size"),
|
||||
icon_name="zoom-original",
|
||||
shortcut="<Primary>0",
|
||||
)
|
||||
@ -199,7 +199,7 @@ class DiagramPage:
|
||||
assert self.view
|
||||
self.view.unselect_all()
|
||||
|
||||
@action(name="diagram.delete", label=translate("_Delete"), icon_name="edit-delete")
|
||||
@action(name="diagram.delete", label=gettext("_Delete"), icon_name="edit-delete")
|
||||
@transactional
|
||||
def delete_selected_items(self):
|
||||
assert self.view
|
||||
|
@ -11,7 +11,7 @@ from typing import Optional, Sequence, Tuple
|
||||
from gaphas.item import SE
|
||||
|
||||
from gaphor import UML, diagram
|
||||
from gaphor.core import translate
|
||||
from gaphor.core import gettext
|
||||
from gaphor.ui.diagramtools import (
|
||||
DefaultTool,
|
||||
GroupPlacementTool,
|
||||
@ -25,251 +25,236 @@ __all__ = ["DiagramToolbox", "TOOLBOX_ACTIONS"]
|
||||
# Actions: ((section (name, label, icon_name, shortcut)), ...)
|
||||
TOOLBOX_ACTIONS: Sequence[Tuple[str, Sequence[Tuple[str, str, str, Optional[str]]]]] = (
|
||||
(
|
||||
translate("General"),
|
||||
gettext("General"),
|
||||
(
|
||||
(
|
||||
"toolbox-pointer",
|
||||
translate("Pointer"),
|
||||
gettext("Pointer"),
|
||||
"gaphor-pointer-symbolic",
|
||||
"Escape",
|
||||
),
|
||||
("toolbox-line", translate("Line"), "gaphor-line-symbolic", "l"),
|
||||
("toolbox-box", translate("Box"), "gaphor-box-symbolic", "b"),
|
||||
("toolbox-ellipse", translate("Ellipse"), "gaphor-ellipse-symbolic", "e"),
|
||||
("toolbox-comment", translate("Comment"), "gaphor-comment-symbolic", "k"),
|
||||
("toolbox-line", gettext("Line"), "gaphor-line-symbolic", "l"),
|
||||
("toolbox-box", gettext("Box"), "gaphor-box-symbolic", "b"),
|
||||
("toolbox-ellipse", gettext("Ellipse"), "gaphor-ellipse-symbolic", "e"),
|
||||
("toolbox-comment", gettext("Comment"), "gaphor-comment-symbolic", "k"),
|
||||
(
|
||||
"toolbox-comment-line",
|
||||
translate("Comment line"),
|
||||
gettext("Comment line"),
|
||||
"gaphor-comment-line-symbolic",
|
||||
"<Shift>K",
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
translate("Classes"),
|
||||
gettext("Classes"),
|
||||
(
|
||||
("toolbox-class", translate("Class"), "gaphor-class-symbolic", "c"),
|
||||
("toolbox-class", gettext("Class"), "gaphor-class-symbolic", "c"),
|
||||
(
|
||||
"toolbox-interface",
|
||||
translate("Interface"),
|
||||
gettext("Interface"),
|
||||
"gaphor-interface-symbolic",
|
||||
"i",
|
||||
),
|
||||
("toolbox-package", translate("Package"), "gaphor-package-symbolic", "p"),
|
||||
("toolbox-package", gettext("Package"), "gaphor-package-symbolic", "p"),
|
||||
(
|
||||
"toolbox-association",
|
||||
translate("Association"),
|
||||
gettext("Association"),
|
||||
"gaphor-association-symbolic",
|
||||
"<Shift>A",
|
||||
),
|
||||
(
|
||||
"toolbox-dependency",
|
||||
translate("Dependency"),
|
||||
gettext("Dependency"),
|
||||
"gaphor-dependency-symbolic",
|
||||
"<Shift>D",
|
||||
),
|
||||
(
|
||||
"toolbox-generalization",
|
||||
translate("Generalization"),
|
||||
gettext("Generalization"),
|
||||
"gaphor-generalization-symbolic",
|
||||
"<Shift>G",
|
||||
),
|
||||
(
|
||||
"toolbox-implementation",
|
||||
translate("Implementation"),
|
||||
gettext("Implementation"),
|
||||
"gaphor-implementation-symbolic",
|
||||
"<Shift>I",
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
translate("Components"),
|
||||
gettext("Components"),
|
||||
(
|
||||
(
|
||||
"toolbox-component",
|
||||
translate("Component"),
|
||||
gettext("Component"),
|
||||
"gaphor-component-symbolic",
|
||||
"o",
|
||||
),
|
||||
(
|
||||
"toolbox-artifact",
|
||||
translate("Artifact"),
|
||||
"gaphor-artifact-symbolic",
|
||||
"h",
|
||||
),
|
||||
("toolbox-node", translate("Node"), "gaphor-node-symbolic", "n"),
|
||||
("toolbox-device", translate("Device"), "gaphor-device-symbolic", "d"),
|
||||
("toolbox-artifact", gettext("Artifact"), "gaphor-artifact-symbolic", "h",),
|
||||
("toolbox-node", gettext("Node"), "gaphor-node-symbolic", "n"),
|
||||
("toolbox-device", gettext("Device"), "gaphor-device-symbolic", "d"),
|
||||
(
|
||||
"toolbox-connector",
|
||||
translate("Connector"),
|
||||
gettext("Connector"),
|
||||
"gaphor-connector-symbolic",
|
||||
"<Shift>C",
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
translate("Actions"),
|
||||
gettext("Actions"),
|
||||
(
|
||||
("toolbox-action", translate("Action"), "gaphor-action-symbolic", "a"),
|
||||
("toolbox-action", gettext("Action"), "gaphor-action-symbolic", "a"),
|
||||
(
|
||||
"toolbox-initial-node",
|
||||
translate("Initial node"),
|
||||
gettext("Initial node"),
|
||||
"gaphor-initial-node-symbolic",
|
||||
"j",
|
||||
),
|
||||
(
|
||||
"toolbox-activity-final-node",
|
||||
translate("Activity final node"),
|
||||
gettext("Activity final node"),
|
||||
"gaphor-activity-final-node-symbolic",
|
||||
"f",
|
||||
),
|
||||
(
|
||||
"toolbox-flow-final-node",
|
||||
translate("Flow final node"),
|
||||
gettext("Flow final node"),
|
||||
"gaphor-flow-final-node-symbolic",
|
||||
"w",
|
||||
),
|
||||
(
|
||||
"toolbox-decision-node",
|
||||
translate("Decision/merge node"),
|
||||
gettext("Decision/merge node"),
|
||||
"gaphor-decision-node-symbolic",
|
||||
"g",
|
||||
),
|
||||
(
|
||||
"toolbox-fork-node",
|
||||
translate("Fork/join node"),
|
||||
gettext("Fork/join node"),
|
||||
"gaphor-fork-node-symbolic",
|
||||
"<Shift>R",
|
||||
),
|
||||
(
|
||||
"toolbox-object-node",
|
||||
translate("Object node"),
|
||||
gettext("Object node"),
|
||||
"gaphor-object-node-symbolic",
|
||||
"<Shift>O",
|
||||
),
|
||||
(
|
||||
"toolbox-partition",
|
||||
translate("Partition"),
|
||||
gettext("Partition"),
|
||||
"gaphor-partition-symbolic",
|
||||
"<Shift>P",
|
||||
),
|
||||
(
|
||||
"toolbox-flow",
|
||||
translate("Control/object flow"),
|
||||
gettext("Control/object flow"),
|
||||
"gaphor-control-flow-symbolic",
|
||||
"<Shift>F",
|
||||
),
|
||||
(
|
||||
"toolbox-send-signal-action",
|
||||
translate("Send signal action"),
|
||||
gettext("Send signal action"),
|
||||
"gaphor-send-signal-action-symbolic",
|
||||
None,
|
||||
),
|
||||
(
|
||||
"toolbox-accept-event-action",
|
||||
translate("Accept event action"),
|
||||
gettext("Accept event action"),
|
||||
"gaphor-accept-event-action-symbolic",
|
||||
None,
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
translate("Interactions"),
|
||||
gettext("Interactions"),
|
||||
(
|
||||
(
|
||||
"toolbox-lifeline",
|
||||
translate("Lifeline"),
|
||||
"gaphor-lifeline-symbolic",
|
||||
"v",
|
||||
),
|
||||
("toolbox-message", translate("Message"), "gaphor-message-symbolic", "M"),
|
||||
("toolbox-lifeline", gettext("Lifeline"), "gaphor-lifeline-symbolic", "v",),
|
||||
("toolbox-message", gettext("Message"), "gaphor-message-symbolic", "M"),
|
||||
(
|
||||
"toolbox-interaction",
|
||||
translate("Interaction"),
|
||||
gettext("Interaction"),
|
||||
"gaphor-interaction-symbolic",
|
||||
"<Shift>N",
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
translate("States"),
|
||||
gettext("States"),
|
||||
(
|
||||
("toolbox-state", translate("State"), "gaphor-state-symbolic", "s"),
|
||||
("toolbox-state", gettext("State"), "gaphor-state-symbolic", "s"),
|
||||
(
|
||||
"toolbox-initial-pseudostate",
|
||||
translate("Initial Pseudostate"),
|
||||
gettext("Initial Pseudostate"),
|
||||
"gaphor-initial-pseudostate-symbolic",
|
||||
"<Shift>S",
|
||||
),
|
||||
(
|
||||
"toolbox-final-state",
|
||||
translate("Final State"),
|
||||
gettext("Final State"),
|
||||
"gaphor-final-state-symbolic",
|
||||
"x",
|
||||
),
|
||||
(
|
||||
"toolbox-history-pseudostate",
|
||||
translate("History Pseudostate"),
|
||||
gettext("History Pseudostate"),
|
||||
"gaphor-pseudostate-symbolic",
|
||||
"q",
|
||||
),
|
||||
(
|
||||
"toolbox-transition",
|
||||
translate("Transition"),
|
||||
gettext("Transition"),
|
||||
"gaphor-transition-symbolic",
|
||||
"<Shift>T",
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
translate("Use Cases"),
|
||||
gettext("Use Cases"),
|
||||
(
|
||||
(
|
||||
"toolbox-use-case",
|
||||
translate("Use case"),
|
||||
"gaphor-use-case-symbolic",
|
||||
"u",
|
||||
),
|
||||
("toolbox-actor", translate("Actor"), "gaphor-actor-symbolic", "t"),
|
||||
("toolbox-use-case", gettext("Use case"), "gaphor-use-case-symbolic", "u",),
|
||||
("toolbox-actor", gettext("Actor"), "gaphor-actor-symbolic", "t"),
|
||||
(
|
||||
"toolbox-use-case-association",
|
||||
translate("Association"),
|
||||
gettext("Association"),
|
||||
"gaphor-association-symbolic",
|
||||
"<Shift>B",
|
||||
),
|
||||
(
|
||||
"toolbox-include",
|
||||
translate("Include"),
|
||||
gettext("Include"),
|
||||
"gaphor-include-symbolic",
|
||||
"<Shift>U",
|
||||
),
|
||||
(
|
||||
"toolbox-extend",
|
||||
translate("Extend"),
|
||||
gettext("Extend"),
|
||||
"gaphor-extend-symbolic",
|
||||
"<Shift>X",
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
translate("Profiles"),
|
||||
gettext("Profiles"),
|
||||
(
|
||||
("toolbox-profile", translate("Profile"), "gaphor-profile-symbolic", "r"),
|
||||
("toolbox-profile", gettext("Profile"), "gaphor-profile-symbolic", "r"),
|
||||
(
|
||||
"toolbox-metaclass",
|
||||
translate("Metaclass"),
|
||||
gettext("Metaclass"),
|
||||
"gaphor-metaclass-symbolic",
|
||||
"m",
|
||||
),
|
||||
(
|
||||
"toolbox-stereotype",
|
||||
translate("Stereotype"),
|
||||
gettext("Stereotype"),
|
||||
"gaphor-stereotype-symbolic",
|
||||
"z",
|
||||
),
|
||||
(
|
||||
"toolbox-extension",
|
||||
translate("Extension"),
|
||||
gettext("Extension"),
|
||||
"gaphor-extension-symbolic",
|
||||
"<Shift>E",
|
||||
),
|
||||
|
@ -6,7 +6,7 @@ from typing import Optional
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor.abc import ActionProvider
|
||||
from gaphor.core import action, event_handler, primary, translate
|
||||
from gaphor.core import action, event_handler, gettext, primary
|
||||
from gaphor.diagram.propertypages import PropertyPages
|
||||
from gaphor.ui.abc import UIComponent
|
||||
from gaphor.ui.event import DiagramSelectionChanged
|
||||
@ -34,7 +34,7 @@ def undo_buttons():
|
||||
icon_button(
|
||||
"edit-undo-symbolic",
|
||||
"win.edit-undo",
|
||||
translate("Undo") + f" ({primary()}+Z)",
|
||||
gettext("Undo") + f" ({primary()}+Z)",
|
||||
),
|
||||
False,
|
||||
False,
|
||||
@ -44,7 +44,7 @@ def undo_buttons():
|
||||
icon_button(
|
||||
"edit-redo-symbolic",
|
||||
"win.edit-redo",
|
||||
translate("Redo") + f" ({primary()}+Shift+Z)",
|
||||
gettext("Redo") + f" ({primary()}+Shift+Z)",
|
||||
),
|
||||
False,
|
||||
True,
|
||||
@ -61,7 +61,7 @@ def zoom_buttons():
|
||||
icon_button(
|
||||
"zoom-in-symbolic",
|
||||
"diagram.zoom-in",
|
||||
translate("Zoom in") + f" ({primary()}++)",
|
||||
gettext("Zoom in") + f" ({primary()}++)",
|
||||
),
|
||||
False,
|
||||
False,
|
||||
@ -71,7 +71,7 @@ def zoom_buttons():
|
||||
icon_button(
|
||||
"zoom-original-symbolic",
|
||||
"diagram.zoom-100",
|
||||
translate("Zoom 100%") + f" ({primary()}+0)",
|
||||
gettext("Zoom 100%") + f" ({primary()}+0)",
|
||||
),
|
||||
False,
|
||||
False,
|
||||
@ -81,7 +81,7 @@ def zoom_buttons():
|
||||
icon_button(
|
||||
"zoom-out-symbolic",
|
||||
"diagram.zoom-out",
|
||||
translate("Zoom out") + f" ({primary()}+-)",
|
||||
gettext("Zoom out") + f" ({primary()}+-)",
|
||||
),
|
||||
False,
|
||||
False,
|
||||
@ -96,7 +96,7 @@ class ElementEditor(UIComponent, ActionProvider):
|
||||
It will display the properties of the currently selected element in the
|
||||
diagram."""
|
||||
|
||||
title = translate("Element Editor")
|
||||
title = gettext("Element Editor")
|
||||
size = (275, -1)
|
||||
|
||||
def __init__(self, event_manager, element_factory, diagrams):
|
||||
@ -108,7 +108,7 @@ class ElementEditor(UIComponent, ActionProvider):
|
||||
self.diagrams = diagrams
|
||||
self.vbox: Optional[Gtk.Box] = None
|
||||
self._current_item = None
|
||||
self._expanded_pages = {translate("Properties"): True}
|
||||
self._expanded_pages = {gettext("Properties"): True}
|
||||
|
||||
def open(self):
|
||||
"""Display the ElementEditor pane."""
|
||||
@ -125,7 +125,7 @@ class ElementEditor(UIComponent, ActionProvider):
|
||||
vbox.pack_start(sep, False, False, 0)
|
||||
sep.show()
|
||||
|
||||
label = Gtk.Label.new(translate("Element Editor"))
|
||||
label = Gtk.Label.new(gettext("Element Editor"))
|
||||
vbox.pack_start(label, False, False, 0)
|
||||
label.show()
|
||||
|
||||
|
@ -11,7 +11,7 @@ from gi.repository import Gtk
|
||||
import gaphor.ui
|
||||
from gaphor import UML
|
||||
from gaphor.abc import ActionProvider, Service
|
||||
from gaphor.core import action, event_handler, translate
|
||||
from gaphor.core import action, event_handler, gettext
|
||||
from gaphor.misc.errorhandler import error_handler
|
||||
from gaphor.misc.gidlethread import GIdleThread, Queue, QueueEmpty, QueueFull
|
||||
from gaphor.misc.xmlwriter import XMLWriter
|
||||
@ -71,8 +71,8 @@ class FileManager(Service, ActionProvider):
|
||||
status_window: Optional[StatusWindow]
|
||||
main_window = self.main_window
|
||||
status_window = StatusWindow(
|
||||
translate("Loading..."),
|
||||
translate(f"Loading model from {filename}"),
|
||||
gettext("Loading..."),
|
||||
gettext(f"Loading model from {filename}"),
|
||||
parent=main_window.window,
|
||||
queue=queue,
|
||||
)
|
||||
@ -93,7 +93,7 @@ class FileManager(Service, ActionProvider):
|
||||
self.event_manager.handle(FileLoaded(self, filename))
|
||||
except (QueueEmpty, QueueFull):
|
||||
error_handler(
|
||||
message=translate("Error while loading model from file %s") % filename
|
||||
message=gettext("Error while loading model from file %s") % filename
|
||||
)
|
||||
raise
|
||||
finally:
|
||||
@ -112,7 +112,7 @@ class FileManager(Service, ActionProvider):
|
||||
main_window = self.main_window
|
||||
|
||||
dialog = QuestionDialog(
|
||||
translate(
|
||||
gettext(
|
||||
"The model contains some references"
|
||||
" to items that are not maintained."
|
||||
" Do you want to clean this before"
|
||||
@ -154,8 +154,8 @@ class FileManager(Service, ActionProvider):
|
||||
main_window = self.main_window
|
||||
queue = Queue()
|
||||
status_window = StatusWindow(
|
||||
translate("Saving..."),
|
||||
translate("Saving model to %s") % filename,
|
||||
gettext("Saving..."),
|
||||
gettext("Saving model to %s") % filename,
|
||||
parent=main_window.window,
|
||||
queue=queue,
|
||||
)
|
||||
@ -173,7 +173,7 @@ class FileManager(Service, ActionProvider):
|
||||
self.event_manager.handle(FileSaved(self, filename))
|
||||
except (OSError, QueueEmpty, QueueFull):
|
||||
error_handler(
|
||||
message=translate("Error while saving model to file %s") % filename
|
||||
message=gettext("Error while saving model to file %s") % filename
|
||||
)
|
||||
raise
|
||||
finally:
|
||||
@ -225,7 +225,7 @@ class FileManager(Service, ActionProvider):
|
||||
|
||||
if element_factory.size():
|
||||
dialog = QuestionDialog(
|
||||
translate(
|
||||
gettext(
|
||||
"Opening a new model will flush the"
|
||||
" currently loaded model.\nAny changes"
|
||||
" made will not be saved. Do you want to"
|
||||
@ -243,10 +243,10 @@ class FileManager(Service, ActionProvider):
|
||||
element_factory.flush()
|
||||
with element_factory.block_events():
|
||||
model = element_factory.create(UML.Package)
|
||||
model.name = translate("New model")
|
||||
model.name = gettext("New model")
|
||||
diagram = element_factory.create(UML.Diagram)
|
||||
diagram.package = model
|
||||
diagram.name = translate("main")
|
||||
diagram.name = gettext("main")
|
||||
self.filename = None
|
||||
element_factory.model_ready()
|
||||
|
||||
@ -258,12 +258,12 @@ class FileManager(Service, ActionProvider):
|
||||
"""This menu action opens the new model from template dialog."""
|
||||
|
||||
filters = [
|
||||
{"name": translate("Gaphor Models"), "pattern": "*.gaphor"},
|
||||
{"name": translate("All Files"), "pattern": "*"},
|
||||
{"name": gettext("Gaphor Models"), "pattern": "*.gaphor"},
|
||||
{"name": gettext("All Files"), "pattern": "*"},
|
||||
]
|
||||
|
||||
file_dialog = FileDialog(
|
||||
translate("New Gaphor Model From Template"), filters=filters
|
||||
gettext("New Gaphor Model From Template"), filters=filters
|
||||
)
|
||||
|
||||
filename = file_dialog.selection
|
||||
@ -281,11 +281,11 @@ class FileManager(Service, ActionProvider):
|
||||
"""This menu action opens the standard model open dialog."""
|
||||
|
||||
filters = [
|
||||
{"name": translate("Gaphor Models"), "pattern": "*.gaphor"},
|
||||
{"name": translate("All Files"), "pattern": "*"},
|
||||
{"name": gettext("Gaphor Models"), "pattern": "*.gaphor"},
|
||||
{"name": gettext("All Files"), "pattern": "*"},
|
||||
]
|
||||
|
||||
file_dialog = FileDialog(translate("Open Gaphor Model"), filters=filters)
|
||||
file_dialog = FileDialog(gettext("Open Gaphor Model"), filters=filters)
|
||||
|
||||
filename = file_dialog.selection
|
||||
|
||||
@ -329,7 +329,7 @@ class FileManager(Service, ActionProvider):
|
||||
"""
|
||||
|
||||
file_dialog = FileDialog(
|
||||
translate("Save Gaphor Model As"), action="save", filename=self.filename
|
||||
gettext("Save Gaphor Model As"), action="save", filename=self.filename
|
||||
)
|
||||
|
||||
filename = file_dialog.selection
|
||||
@ -355,15 +355,13 @@ class FileManager(Service, ActionProvider):
|
||||
Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
||||
Gtk.MessageType.WARNING,
|
||||
Gtk.ButtonsType.NONE,
|
||||
translate("Save changed to your model before closing?"),
|
||||
gettext("Save changed to your model before closing?"),
|
||||
)
|
||||
dialog.format_secondary_text(
|
||||
translate(
|
||||
"If you close without saving, your changes will be discarded."
|
||||
)
|
||||
gettext("If you close without saving, your changes will be discarded.")
|
||||
)
|
||||
dialog.add_buttons(
|
||||
translate("Close _without saving"),
|
||||
gettext("Close _without saving"),
|
||||
Gtk.ResponseType.REJECT,
|
||||
Gtk.STOCK_CANCEL,
|
||||
Gtk.ResponseType.CANCEL,
|
||||
|
@ -11,7 +11,7 @@ from gi.repository import Gdk, Gio, GLib, Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.abc import ActionProvider, Service
|
||||
from gaphor.core import event_handler, translate
|
||||
from gaphor.core import event_handler, gettext
|
||||
from gaphor.event import ActionEnabled
|
||||
from gaphor.services.undomanager import UndoManagerStateChanged
|
||||
from gaphor.ui import APPLICATION_ID
|
||||
@ -59,7 +59,7 @@ class RecentFilesMenu(Gio.Menu):
|
||||
break
|
||||
if self.get_n_items() == 0:
|
||||
self.append_item(
|
||||
Gio.MenuItem.new(translate("No recently opened models"), None)
|
||||
Gio.MenuItem.new(gettext("No recently opened models"), None)
|
||||
)
|
||||
|
||||
|
||||
@ -76,22 +76,22 @@ def create_hamburger_model(export_menu, tools_menu):
|
||||
model = Gio.Menu.new()
|
||||
|
||||
part = Gio.Menu.new()
|
||||
part.append(translate("New"), "win.file-new")
|
||||
part.append(translate("New from Template"), "win.file-new-template")
|
||||
part.append(gettext("New"), "win.file-new")
|
||||
part.append(gettext("New from Template"), "win.file-new-template")
|
||||
model.append_section(None, part)
|
||||
|
||||
part = Gio.Menu.new()
|
||||
part.append(translate("Save As..."), "win.file-save-as")
|
||||
part.append_submenu(translate("Export"), export_menu)
|
||||
part.append(gettext("Save As..."), "win.file-save-as")
|
||||
part.append_submenu(gettext("Export"), export_menu)
|
||||
model.append_section(None, part)
|
||||
|
||||
part = Gio.Menu.new()
|
||||
part.append_submenu(translate("Tools"), tools_menu)
|
||||
part.append_submenu(gettext("Tools"), tools_menu)
|
||||
model.append_section(None, part)
|
||||
|
||||
part = Gio.Menu.new()
|
||||
part.append(translate("Preferences"), "app.preferences")
|
||||
part.append(translate("About Gaphor"), "app.about")
|
||||
part.append(gettext("Preferences"), "app.preferences")
|
||||
part.append(gettext("About Gaphor"), "app.about")
|
||||
model.append_section(None, part)
|
||||
|
||||
return model
|
||||
@ -104,7 +104,7 @@ def create_recent_files_button(recent_manager=None):
|
||||
|
||||
model = Gio.Menu.new()
|
||||
model.append_section(
|
||||
translate("Recently opened files"),
|
||||
gettext("Recently opened files"),
|
||||
RecentFilesMenu(recent_manager or Gtk.RecentManager.get_default()),
|
||||
)
|
||||
|
||||
@ -193,9 +193,7 @@ class MainWindow(Service, ActionProvider):
|
||||
|
||||
button_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
||||
button_box.get_style_context().add_class("linked")
|
||||
button_box.pack_start(
|
||||
button(translate("Open"), "win.file-open"), False, False, 0
|
||||
)
|
||||
button_box.pack_start(button(gettext("Open"), "win.file-open"), False, False, 0)
|
||||
button_box.pack_start(create_recent_files_button(), False, False, 0)
|
||||
button_box.show()
|
||||
header.pack_start(button_box)
|
||||
@ -211,7 +209,7 @@ class MainWindow(Service, ActionProvider):
|
||||
create_hamburger_model(self.export_menu.menu, self.tools_menu.menu)
|
||||
)
|
||||
)
|
||||
header.pack_end(button(translate("Save"), "win.file-save"))
|
||||
header.pack_end(button(gettext("Save"), "win.file-save"))
|
||||
|
||||
b = Gtk.MenuButton.new()
|
||||
image = Gtk.Image.new_from_icon_name(
|
||||
@ -280,7 +278,7 @@ class MainWindow(Service, ActionProvider):
|
||||
title = self.title
|
||||
subtitle = ""
|
||||
if self.model_changed:
|
||||
title += translate(" [edited]")
|
||||
title += gettext(" [edited]")
|
||||
self.window.set_title(title)
|
||||
self.window.get_titlebar().set_subtitle(subtitle)
|
||||
|
||||
@ -348,7 +346,7 @@ Gtk.AccelMap.add_filter("gaphor")
|
||||
|
||||
class Diagrams(UIComponent, ActionProvider):
|
||||
|
||||
title = translate("Diagrams")
|
||||
title = gettext("Diagrams")
|
||||
|
||||
def __init__(self, event_manager, element_factory, properties):
|
||||
self.event_manager = event_manager
|
||||
|
@ -12,7 +12,7 @@ from typing import TYPE_CHECKING, Optional
|
||||
from gi.repository import Gdk, Gio, GLib, GObject, Gtk
|
||||
|
||||
from gaphor import UML
|
||||
from gaphor.core import action, event_handler, transactional, translate
|
||||
from gaphor.core import action, event_handler, gettext, transactional
|
||||
from gaphor.ui.abc import UIComponent
|
||||
from gaphor.ui.actiongroup import create_action_group
|
||||
from gaphor.ui.event import DiagramOpened
|
||||
@ -261,7 +261,7 @@ class NamespaceView(Gtk.TreeView):
|
||||
|
||||
class Namespace(UIComponent):
|
||||
|
||||
title = translate("Namespace")
|
||||
title = gettext("Namespace")
|
||||
|
||||
def __init__(self, event_manager: EventManager, element_factory: ElementFactory):
|
||||
self.event_manager = event_manager
|
||||
@ -363,17 +363,17 @@ class Namespace(UIComponent):
|
||||
model = Gio.Menu.new()
|
||||
|
||||
part = Gio.Menu.new()
|
||||
part.append(translate("_Open"), "tree-view.open")
|
||||
part.append(translate("_Rename"), "tree-view.rename")
|
||||
part.append(gettext("_Open"), "tree-view.open")
|
||||
part.append(gettext("_Rename"), "tree-view.rename")
|
||||
model.append_section(None, part)
|
||||
|
||||
part = Gio.Menu.new()
|
||||
part.append(translate("New _Diagram"), "tree-view.create-diagram")
|
||||
part.append(translate("New _Package"), "tree-view.create-package")
|
||||
part.append(gettext("New _Diagram"), "tree-view.create-diagram")
|
||||
part.append(gettext("New _Package"), "tree-view.create-package")
|
||||
model.append_section(None, part)
|
||||
|
||||
part = Gio.Menu.new()
|
||||
part.append(translate("De_lete"), "tree-view.delete")
|
||||
part.append(gettext("De_lete"), "tree-view.delete")
|
||||
model.append_section(None, part)
|
||||
|
||||
element = self._namespace.get_selected_element()
|
||||
@ -382,7 +382,7 @@ class Namespace(UIComponent):
|
||||
for presentation in element.presentation:
|
||||
diagram = presentation.canvas.diagram
|
||||
menu_item = Gio.MenuItem.new(
|
||||
translate(f'Show in "{diagram.name}"'), "tree-view.show-in-diagram"
|
||||
gettext(f'Show in "{diagram.name}"'), "tree-view.show-in-diagram"
|
||||
)
|
||||
menu_item.set_attribute_value("target", GLib.Variant.new_string(diagram.id))
|
||||
part.append_item(menu_item)
|
||||
|
@ -8,7 +8,7 @@ import logging
|
||||
from gi.repository import Gdk, GLib, Gtk
|
||||
|
||||
from gaphor.abc import ActionProvider
|
||||
from gaphor.core import translate
|
||||
from gaphor.core import gettext
|
||||
from gaphor.ui.abc import UIComponent
|
||||
from gaphor.ui.diagramtoolbox import TOOLBOX_ACTIONS
|
||||
|
||||
@ -27,7 +27,7 @@ class Toolbox(UIComponent, ActionProvider):
|
||||
),
|
||||
]
|
||||
|
||||
title = translate("Toolbox")
|
||||
title = gettext("Toolbox")
|
||||
|
||||
def __init__(self, main_window, properties, toolbox_actions=TOOLBOX_ACTIONS):
|
||||
self.main_window = main_window
|
||||
|
Loading…
x
Reference in New Issue
Block a user