From 512c3411648b24505165d555a04e82ba689f8aed Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sun, 19 Aug 2018 22:14:10 -0400 Subject: integrate inx generation into ink/stitch proper --- templates/convert_to_satin.inx | 17 +++++++++++++++++ templates/embroider.inx | 28 ++++++++++++++++++++++++++++ templates/embroider_input.inx | 17 ----------------- templates/embroider_output.inx | 19 ------------------- templates/embroider_zip_output.inx | 21 --------------------- templates/flip.inx | 17 +++++++++++++++++ templates/input.inx | 17 +++++++++++++++++ templates/install.inx | 17 +++++++++++++++++ templates/layer_commands.inx | 19 +++++++++++++++++++ templates/object_commands.inx | 22 ++++++++++++++++++++++ templates/output.inx | 19 +++++++++++++++++++ templates/params.inx | 17 +++++++++++++++++ templates/print.inx | 17 +++++++++++++++++ templates/simulate.inx | 17 +++++++++++++++++ templates/zip.inx | 21 +++++++++++++++++++++ 15 files changed, 228 insertions(+), 57 deletions(-) create mode 100644 templates/convert_to_satin.inx create mode 100644 templates/embroider.inx delete mode 100644 templates/embroider_input.inx delete mode 100644 templates/embroider_output.inx delete mode 100644 templates/embroider_zip_output.inx create mode 100644 templates/flip.inx create mode 100644 templates/input.inx create mode 100644 templates/install.inx create mode 100644 templates/layer_commands.inx create mode 100644 templates/object_commands.inx create mode 100644 templates/output.inx create mode 100644 templates/params.inx create mode 100644 templates/print.inx create mode 100644 templates/simulate.inx create mode 100644 templates/zip.inx (limited to 'templates') diff --git a/templates/convert_to_satin.inx b/templates/convert_to_satin.inx new file mode 100644 index 00000000..d71b2081 --- /dev/null +++ b/templates/convert_to_satin.inx @@ -0,0 +1,17 @@ + + + <_name>Convert Line to Satin + org.inkstitch.convert_to_satin + inkstitch.py + inkex.py + convert_to_satin + + all + + + + + + diff --git a/templates/embroider.inx b/templates/embroider.inx new file mode 100644 index 00000000..7c6544db --- /dev/null +++ b/templates/embroider.inx @@ -0,0 +1,28 @@ + + + <_name>Embroider + jonh.embroider + inkstitch.py + inkex.py + 3.0 + true + + {% for format, description in formats %} + <_option value="{{ format }}">{{ description }} ({{ format | upper }}) + {% endfor %} + {% for format, description in debug_formats %} + <_option value="{{ format }}">{{ description }} ({{ format | upper }}) [DEBUG] + {% endfor %} + + + embroider + + all + + + + + + diff --git a/templates/embroider_input.inx b/templates/embroider_input.inx deleted file mode 100644 index 15ccdef8..00000000 --- a/templates/embroider_input.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>{{ format | upper }} file input - org.inkstitch.input.{{ format }} - inkstitch.py - inkex.py - - .{{ format }} - application/x-embroidery-{{ format }} - <_filetypename>Ink/Stitch: {{ description }} (.{{ format }}) - <_filetypetooltip>convert {{ format | upper }} file to Ink/Stitch manual-stitch paths - - input - - diff --git a/templates/embroider_output.inx b/templates/embroider_output.inx deleted file mode 100644 index 4f971fb3..00000000 --- a/templates/embroider_output.inx +++ /dev/null @@ -1,19 +0,0 @@ - - - <_name>{{ format | upper }} file output - org.inkstitch.output.{{ format }} - inkstitch.py - inkex.py - - .{{ format }} - application/x-embroidery-{{ format }} - <_filetypename>Ink/Stitch: {{ description }} (.{{ format }}) - <_filetypetooltip>Save design in {{ format | upper }} format using Ink/Stitch - true - - output - {{ format }} - - diff --git a/templates/embroider_zip_output.inx b/templates/embroider_zip_output.inx deleted file mode 100644 index 5d162357..00000000 --- a/templates/embroider_zip_output.inx +++ /dev/null @@ -1,21 +0,0 @@ - - - <_name>embroidery ZIP file output - org.inkstitch.output.zip - inkstitch.py - inkex.py - - .zip - application/zip - <_filetypename>Ink/Stitch: ZIP export multiple formats (.zip) - <_filetypetooltip>Create a ZIP with multiple embroidery file formats using Ink/Stitch - true - -{% for format, description in formats %} - false -{% endfor %} - zip - - diff --git a/templates/flip.inx b/templates/flip.inx new file mode 100644 index 00000000..f129b8d9 --- /dev/null +++ b/templates/flip.inx @@ -0,0 +1,17 @@ + + + <_name>Flip Satin Columns + org.inkstitch.flip_satins + inkstitch.py + inkex.py + flip + + all + + + + + + diff --git a/templates/input.inx b/templates/input.inx new file mode 100644 index 00000000..15ccdef8 --- /dev/null +++ b/templates/input.inx @@ -0,0 +1,17 @@ + + + <_name>{{ format | upper }} file input + org.inkstitch.input.{{ format }} + inkstitch.py + inkex.py + + .{{ format }} + application/x-embroidery-{{ format }} + <_filetypename>Ink/Stitch: {{ description }} (.{{ format }}) + <_filetypetooltip>convert {{ format | upper }} file to Ink/Stitch manual-stitch paths + + input + + diff --git a/templates/install.inx b/templates/install.inx new file mode 100644 index 00000000..7275e13a --- /dev/null +++ b/templates/install.inx @@ -0,0 +1,17 @@ + + + <_name>Install add-ons for Inkscape + org.inkstitch.install + inkstitch.py + inkex.py + install + + all + + + + + + diff --git a/templates/layer_commands.inx b/templates/layer_commands.inx new file mode 100644 index 00000000..7eadd094 --- /dev/null +++ b/templates/layer_commands.inx @@ -0,0 +1,19 @@ + + + <_name>Add Layer Commands + org.inkstitch.layer_commands + inkstitch.py + inkex.py + Commands will be added to the currently-selected layer. + false + layer_commands + + all + + + + + + diff --git a/templates/object_commands.inx b/templates/object_commands.inx new file mode 100644 index 00000000..bba8602b --- /dev/null +++ b/templates/object_commands.inx @@ -0,0 +1,22 @@ + + + <_name>Attach Commands + org.inkstitch.commands + inkstitch.py + inkex.py + false + false + false + false + false + object_commands + + all + + + + + + diff --git a/templates/output.inx b/templates/output.inx new file mode 100644 index 00000000..4f971fb3 --- /dev/null +++ b/templates/output.inx @@ -0,0 +1,19 @@ + + + <_name>{{ format | upper }} file output + org.inkstitch.output.{{ format }} + inkstitch.py + inkex.py + + .{{ format }} + application/x-embroidery-{{ format }} + <_filetypename>Ink/Stitch: {{ description }} (.{{ format }}) + <_filetypetooltip>Save design in {{ format | upper }} format using Ink/Stitch + true + + output + {{ format }} + + diff --git a/templates/params.inx b/templates/params.inx new file mode 100644 index 00000000..7b3b4e63 --- /dev/null +++ b/templates/params.inx @@ -0,0 +1,17 @@ + + + <_name>Params + jonh.embroider.params + inkstitch.py + inkex.py + params + + all + + + + + + diff --git a/templates/print.inx b/templates/print.inx new file mode 100644 index 00000000..edc96a4c --- /dev/null +++ b/templates/print.inx @@ -0,0 +1,17 @@ + + + <_name>Print + jonh.embroider.print + inkstitch.py + inkex.py + print + + all + + + + + + diff --git a/templates/simulate.inx b/templates/simulate.inx new file mode 100644 index 00000000..66f892d8 --- /dev/null +++ b/templates/simulate.inx @@ -0,0 +1,17 @@ + + + <_name>Simulate + jonh.embroider.simulate + inkstitch.py + inkex.py + simulate + + all + + + + + + diff --git a/templates/zip.inx b/templates/zip.inx new file mode 100644 index 00000000..c85e849f --- /dev/null +++ b/templates/zip.inx @@ -0,0 +1,21 @@ + + + <_name>embroidery ZIP file output + org.inkstitch.output.zip + inkstitch.py + inkex.py + + .zip + application/zip + <_filetypename>Ink/Stitch: ZIP export multiple formats (.zip) + <_filetypetooltip>Create a ZIP with multiple embroidery file formats using Ink/Stitch + true + + {% for format, description in formats %} + false + {% endfor %} + zip + + -- cgit v1.3.1 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 --- Makefile | 2 +- lib/commands.py | 28 ++++++++++++++-------------- lib/i18n.py | 5 +++++ lib/inx/extensions.py | 5 ++++- messages.po | 14 +++++++------- templates/convert_to_satin.inx | 4 ++-- templates/embroider.inx | 18 +++++++++--------- templates/flip.inx | 4 ++-- templates/input.inx | 6 +++--- templates/install.inx | 4 ++-- templates/layer_commands.inx | 10 ++++++---- templates/object_commands.inx | 13 +++++-------- templates/output.inx | 6 +++--- templates/params.inx | 6 +++--- templates/print.inx | 6 +++--- templates/simulate.inx | 6 +++--- templates/zip.inx | 8 ++++---- 17 files changed, 76 insertions(+), 69 deletions(-) (limited to 'templates') diff --git a/Makefile b/Makefile index a91eabe1..a7fd0e83 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ inx: messages.po: rm -f messages.po bin/pyembroidery-gettext > pyembroidery-format-descriptions.py - pybabel extract -o messages.po -F babel.conf --add-location=full --add-comments=l10n,L10n,L10N --sort-by-file --strip-comments . + pybabel extract -o messages.po -F babel.conf --add-location=full --add-comments=l10n,L10n,L10N --sort-by-file --strip-comments -k N_ . rm pyembroidery-format-descriptions.py .PHONY: locales 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): diff --git a/lib/i18n.py b/lib/i18n.py index d20f5d2f..06e0dd49 100644 --- a/lib/i18n.py +++ b/lib/i18n.py @@ -4,6 +4,11 @@ import gettext _ = translation = None +# Use N_ to mark a string for translation but _not_ immediately translate it. +# reference: https://docs.python.org/3/library/gettext.html#deferred-translations +# Makefile configures pybabel to treat N_() the same as _() +def N_(message): return message + def localize(): if getattr(sys, 'frozen', False): # we are in a pyinstaller installation diff --git a/lib/inx/extensions.py b/lib/inx/extensions.py index ba206d8f..2b097440 100755 --- a/lib/inx/extensions.py +++ b/lib/inx/extensions.py @@ -2,7 +2,7 @@ import pyembroidery from .utils import build_environment, write_inx_file from .outputs import pyembroidery_output_formats -from ..extensions import extensions +from ..extensions import extensions, Input, Output def pyembroidery_debug_formats(): @@ -15,6 +15,9 @@ def generate_extension_inx_files(): env = build_environment() for extension in extensions: + if extension is Input or extension is Output: + continue + name = extension.name() template = env.get_template('%s.inx' % name) write_inx_file(name, template.render(formats=pyembroidery_output_formats(), diff --git a/messages.po b/messages.po index cfe111bc..0dcd185a 100644 --- a/messages.po +++ b/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-08-20 15:17-0400\n" +"POT-Creation-Date: 2018-08-20 15:49-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,32 +17,32 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.5.3\n" -#. : command attached to an object +#. command attached to an object #: lib/commands.py:11 msgid "Fill stitch starting position" msgstr "" -#. : command attached to an object +#. command attached to an object #: lib/commands.py:14 msgid "Fill stitch ending position" msgstr "" -#. : command attached to an object +#. command attached to an object #: lib/commands.py:17 msgid "Stop (pause machine) after sewing this object" msgstr "" -#. : command attached to an object +#. command attached to an object #: lib/commands.py:20 msgid "Trim thread after sewing this object" msgstr "" -#. : command attached to an object +#. command attached to an object #: lib/commands.py:23 msgid "Ignore this object (do not stitch)" msgstr "" -#. : command that affects entire layer +#. command that affects entire layer #: lib/commands.py:26 msgid "Ignore layer (do not stitch any objects in this layer)" msgstr "" diff --git a/templates/convert_to_satin.inx b/templates/convert_to_satin.inx index d71b2081..446e4b5c 100644 --- a/templates/convert_to_satin.inx +++ b/templates/convert_to_satin.inx @@ -1,6 +1,6 @@ - <_name>Convert Line to Satin + {% trans %}Convert Line to Satin{% endtrans %} org.inkstitch.convert_to_satin inkstitch.py inkex.py @@ -8,7 +8,7 @@ all - +