From f99e553d989945e44f81bd56307cb9c9a049b3a2 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 20 Aug 2018 15:07:12 -0400 Subject: add mkdir -p inx bin/generate-inx-files target and gitignore entry --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4c31f17e..1cc223e4 100644 --- a/Makefile +++ b/Makefile @@ -23,11 +23,16 @@ dist: distclean locales distclean: rm -rf build dist *.spec *.tar.gz +.PHONY: inx +inx: + mkdir -p inx + bin/generate-inx-files + +.PHONY: messages.po messages.po: rm -f messages.po pybabel extract -o messages.po -F babel.conf --add-location=full --add-comments=l10n,L10n,L10N --sort-by-file --strip-comments . -.PHONY: messages.po .PHONY: locales locales: # message files will look like this: -- cgit v1.3.1 From f7f59efd7d5117c6b9b43b100df5fe646ea46bc3 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 20 Aug 2018 15:17:55 -0400 Subject: gettextify pyembroidery format descriptions --- Makefile | 2 + bin/pyembroidery-gettext | 10 +++ messages.po | 161 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 172 insertions(+), 1 deletion(-) create mode 100755 bin/pyembroidery-gettext (limited to 'Makefile') diff --git a/Makefile b/Makefile index 1cc223e4..a91eabe1 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,9 @@ inx: .PHONY: messages.po 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 . + rm pyembroidery-format-descriptions.py .PHONY: locales locales: diff --git a/bin/pyembroidery-gettext b/bin/pyembroidery-gettext new file mode 100755 index 00000000..ac9bd1ab --- /dev/null +++ b/bin/pyembroidery-gettext @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +import pyembroidery + + +# generate fake python code containing the descriptions of pyembroidery formats +# as gettext calls so that pybabel will extract them into messages.po +for format in pyembroidery.supported_formats(): + print "# L10N description for pyembroidery file format: %s" % format['extension'] + print "_(%s)" % repr(format['description']) diff --git a/messages.po b/messages.po index 5de56d8f..cfe111bc 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-19 22:14-0400\n" +"POT-Creation-Date: 2018-08-20 15:17-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -943,3 +943,162 @@ msgstr "" msgid "Realistic" msgstr "" +#. description for pyembroidery file format: pec +#. description for pyembroidery file format: pes +#. description for pyembroidery file format: phb +#. description for pyembroidery file format: phc +#: pyembroidery-format-descriptions.py:2 pyembroidery-format-descriptions.py:4 +#: pyembroidery-format-descriptions.py:56 +#: pyembroidery-format-descriptions.py:58 +msgid "Brother Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: exp +#: pyembroidery-format-descriptions.py:6 +msgid "Melco Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: dst +#. description for pyembroidery file format: tbf +#: pyembroidery-format-descriptions.py:8 pyembroidery-format-descriptions.py:48 +msgid "Tajima Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: jef +#. description for pyembroidery file format: sew +#. description for pyembroidery file format: jpx +#: pyembroidery-format-descriptions.py:10 +#: pyembroidery-format-descriptions.py:20 +#: pyembroidery-format-descriptions.py:74 +msgid "Janome Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: vp3 +#. description for pyembroidery file format: ksm +#. description for pyembroidery file format: max +#. description for pyembroidery file format: pcd +#. description for pyembroidery file format: pcq +#. description for pyembroidery file format: pcm +#. description for pyembroidery file format: pcs +#: pyembroidery-format-descriptions.py:12 +#: pyembroidery-format-descriptions.py:50 +#: pyembroidery-format-descriptions.py:62 +#: pyembroidery-format-descriptions.py:66 +#: pyembroidery-format-descriptions.py:68 +#: pyembroidery-format-descriptions.py:70 +#: pyembroidery-format-descriptions.py:72 +msgid "Pfaff Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: svg +#: pyembroidery-format-descriptions.py:14 +msgid "Scalable Vector Graphics" +msgstr "" + +#. description for pyembroidery file format: csv +#: pyembroidery-format-descriptions.py:16 +msgid "Comma-separated values" +msgstr "" + +#. description for pyembroidery file format: xxx +#: pyembroidery-format-descriptions.py:18 +msgid "Singer Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: u01 +#: pyembroidery-format-descriptions.py:22 +msgid "Barudan Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: shv +#: pyembroidery-format-descriptions.py:24 +msgid "Husqvarna Viking Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: 10o +#. description for pyembroidery file format: 100 +#: pyembroidery-format-descriptions.py:26 +#: pyembroidery-format-descriptions.py:28 +msgid "Toyota Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: bro +#: pyembroidery-format-descriptions.py:30 +msgid "Bits & Volts Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: dat +#: pyembroidery-format-descriptions.py:32 +msgid "Sunstar or Barudan Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: dsb +#: pyembroidery-format-descriptions.py:34 +msgid "Tajima(Barudan) Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: dsz +#: pyembroidery-format-descriptions.py:36 +msgid "ZSK USA Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: emd +#: pyembroidery-format-descriptions.py:38 +msgid "Elna Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: exy +#: pyembroidery-format-descriptions.py:40 +msgid "Eltac Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: fxy +#: pyembroidery-format-descriptions.py:42 +msgid "Fortron Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: gt +#: pyembroidery-format-descriptions.py:44 +msgid "Gold Thread Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: inb +#: pyembroidery-format-descriptions.py:46 +msgid "Inbro Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: tap +#: pyembroidery-format-descriptions.py:52 +msgid "Happy Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: stx +#: pyembroidery-format-descriptions.py:54 +msgid "Data Stitch Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: new +#: pyembroidery-format-descriptions.py:60 +msgid "Ameco Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: mit +#: pyembroidery-format-descriptions.py:64 +msgid "Mitsubishi Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: stc +#: pyembroidery-format-descriptions.py:76 +msgid "Gunold Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: zxy +#: pyembroidery-format-descriptions.py:78 +msgid "ZSK TC Embroidery Format" +msgstr "" + +#. description for pyembroidery file format: pmv +#: pyembroidery-format-descriptions.py:80 +msgid "Brother Stitch Format" +msgstr "" + -- 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 'Makefile') 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 - +