From 13016f50ecace38a93f7d8e55bdad8b21fb0d2c7 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 17 Aug 2018 20:55:43 -0400 Subject: group symbol+connector and label with command description --- lib/commands.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'lib/commands.py') diff --git a/lib/commands.py b/lib/commands.py index cadfa080..5a471c2e 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -3,13 +3,42 @@ import cubicsuperpath from .svg import apply_transforms from .svg.tags import SVG_USE_TAG, SVG_SYMBOL_TAG, CONNECTION_START, CONNECTION_END, XLINK_HREF +from .utils import cache +from .i18n import _ +COMMANDS = { + # l10n: command attached to an object + "fill_start": _("Fill stitch starting position"), + + # l10n: command attached to an object + "fill_end": _("Fill stitch ending position"), + + # l10n: command attached to an object + "stop": _("Stop (pause machine) after sewing this object"), + + # l10n: command attached to an object + "trim": _("Trim thread after sewing this object"), + + # l10n: command attached to an object + "ignore_object": _("Ignore this object (do not stitch)"), + + # l10n: command that affects entire layer + "ignore_layer": _("Ignore layer (do not stitch any objects in this layer)") +} + +OBJECT_COMMANDS = [ "fill_start", "fill_end", "stop", "trim", "ignore_object" ] +LAYER_COMMANDS = [ "ignore_layer" ] class CommandParseError(Exception): pass class BaseCommand(object): + @property + @cache + def description(self): + return get_command_description(self.command) + def parse_symbol(self): if self.symbol.tag != SVG_SYMBOL_TAG: raise CommandParseError("use points to non-symbol") @@ -87,6 +116,9 @@ class StandaloneCommand(BaseCommand): self.parse_symbol() +def get_command_description(command): + return COMMANDS[command] + def find_commands(node): """Find the symbols this node is connected to and return them as Commands""" -- cgit v1.2.3 From 871358d990d4a06b2eaaf0e405f2d18e26753d52 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 20 Aug 2018 15:49:19 -0400 Subject: gettextify INX templates --- lib/commands.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'lib/commands.py') diff --git a/lib/commands.py b/lib/commands.py index 5a471c2e..214b5f40 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -4,26 +4,26 @@ import cubicsuperpath from .svg import apply_transforms from .svg.tags import SVG_USE_TAG, SVG_SYMBOL_TAG, CONNECTION_START, CONNECTION_END, XLINK_HREF from .utils import cache -from .i18n import _ +from .i18n import _, N_ COMMANDS = { - # l10n: command attached to an object - "fill_start": _("Fill stitch starting position"), + # L10N command attached to an object + "fill_start": N_("Fill stitch starting position"), - # l10n: command attached to an object - "fill_end": _("Fill stitch ending position"), + # L10N command attached to an object + "fill_end": N_("Fill stitch ending position"), - # l10n: command attached to an object - "stop": _("Stop (pause machine) after sewing this object"), + # L10N command attached to an object + "stop": N_("Stop (pause machine) after sewing this object"), - # l10n: command attached to an object - "trim": _("Trim thread after sewing this object"), + # L10N command attached to an object + "trim": N_("Trim thread after sewing this object"), - # l10n: command attached to an object - "ignore_object": _("Ignore this object (do not stitch)"), + # L10N command attached to an object + "ignore_object": N_("Ignore this object (do not stitch)"), - # l10n: command that affects entire layer - "ignore_layer": _("Ignore layer (do not stitch any objects in this layer)") + # L10N command that affects entire layer + "ignore_layer": N_("Ignore layer (do not stitch any objects in this layer)") } OBJECT_COMMANDS = [ "fill_start", "fill_end", "stop", "trim", "ignore_object" ] @@ -117,7 +117,7 @@ class StandaloneCommand(BaseCommand): self.parse_symbol() def get_command_description(command): - return COMMANDS[command] + return _(COMMANDS[command]) def find_commands(node): -- cgit v1.2.3