generate INX files for all languages

pull/286/head
Lex Neva 2018-08-20 20:42:02 -04:00
rodzic 871358d990
commit a2cad1f522
18 zmienionych plików z 207 dodań i 54 usunięć

Wyświetl plik

@ -24,7 +24,7 @@ distclean:
rm -rf build dist *.spec *.tar.gz
.PHONY: inx
inx:
inx: locales
mkdir -p inx
bin/generate-inx-files

Wyświetl plik

@ -3,4 +3,4 @@
[python: **.py]
[jinja2: print/templates/*.html]
[jinja2: templates/*]

Wyświetl plik

@ -1,26 +1,32 @@
import sys
import os
from os.path import dirname, realpath
import gettext
_ = translation = None
locale_dir = 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():
def _set_locale_dir():
global locale_dir
if getattr(sys, 'frozen', False):
# we are in a pyinstaller installation
locale_dir = sys._MEIPASS
else:
locale_dir = os.path.dirname(__file__)
locale_dir = dirname(dirname(realpath(__file__)))
locale_dir = os.path.join(locale_dir, 'locales')
def localize(languages=None):
global translation, _
translation = gettext.translation("inkstitch", locale_dir, fallback=True)
_ = translation.gettext
_set_locale_dir()
localize()

Wyświetl plik

@ -1,8 +1,12 @@
import os
from .inputs import generate_input_inx_files
from .outputs import generate_output_inx_files
from .extensions import generate_extension_inx_files
from .utils import iterate_inx_locales, inx_path
def generate_inx_files():
generate_input_inx_files()
generate_output_inx_files()
generate_extension_inx_files()
for locale in iterate_inx_locales():
generate_input_inx_files()
generate_output_inx_files()
generate_extension_inx_files()

Wyświetl plik

@ -1,14 +1,18 @@
import os
import gettext
from os.path import dirname
from jinja2 import Environment, FileSystemLoader
from ..i18n import translation as inkstitch_translation
from ..i18n import translation as default_translation, locale_dir, _, N_
_top_path = dirname(dirname(dirname(os.path.realpath(__file__))))
inx_path = os.path.join(_top_path, "inx")
template_path = os.path.join(_top_path, "templates")
current_translation = default_translation
current_locale = "en_US"
def build_environment():
env = Environment(
loader = FileSystemLoader(template_path),
@ -16,11 +20,30 @@ def build_environment():
extensions=['jinja2.ext.i18n']
)
env.install_gettext_translations(inkstitch_translation)
env.install_gettext_translations(current_translation)
env.globals["locale"] = current_locale
return env
def write_inx_file(name, contents):
inx_file_name = "inkstitch_%s.inx" % name
inx_file_name = "inkstitch_%s_%s.inx" % (name, current_locale)
with open(os.path.join(inx_path, inx_file_name), 'w') as inx_file:
print >> inx_file, contents
def iterate_inx_locales():
global current_translation, current_locale
locales = sorted(os.listdir(locale_dir))
for locale in locales:
translation = gettext.translation("inkstitch", locale_dir, languages=[locale], fallback=True)
# L10N If you translate this string, that will tell Ink/Stitch to
# generate menu items for this language in Inkscape's "Extensions"
# menu.
magic_string = N_("Generate INX files")
translated_magic_string = translation.gettext(magic_string)
if translated_magic_string != magic_string or locale == "en_US":
current_translation = translation
current_locale = locale
yield locale

Wyświetl plik

@ -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:49-0400\n"
"POT-Creation-Date: 2018-08-20 20:42-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -608,6 +608,13 @@ msgstr ""
msgid "No embroidery file formats selected."
msgstr ""
#. If you translate this string, that will tell Ink/Stitch to
#. generate menu items for this language in Inkscape's "Extensions"
#. menu.
#: lib/inx/utils.py:43
msgid "Generate INX files"
msgstr ""
#: lib/simulator.py:40
msgid "Speed up"
msgstr ""
@ -844,7 +851,7 @@ msgstr ""
msgid "Ink/Stitch Print Preview"
msgstr ""
#: print/templates/ui.html:4
#: print/templates/ui.html:4 templates/print.inx:3
msgid "Print"
msgstr ""
@ -1102,3 +1109,98 @@ msgstr ""
msgid "Brother Stitch Format"
msgstr ""
#: templates/convert_to_satin.inx:3
msgid "Convert Line to Satin"
msgstr ""
#: templates/convert_to_satin.inx:12 templates/embroider.inx:23
#: templates/flip.inx:12 templates/install.inx:12
#: templates/layer_commands.inx:16 templates/object_commands.inx:14
#: templates/params.inx:12 templates/print.inx:12 templates/simulate.inx:12
msgid "English"
msgstr ""
#: templates/embroider.inx:3
msgid "Embroider"
msgstr ""
#: templates/embroider.inx:7
msgid "Collapse length (mm)"
msgstr ""
#: templates/embroider.inx:7
msgid "Jump stitches smaller than this will be treated as normal stitches."
msgstr ""
#: templates/embroider.inx:8
msgid "Hide other layers"
msgstr ""
#: templates/embroider.inx:8
msgid ""
"Hide all other top-level layers when the embroidery layer is generated, "
"in order to make stitching discernible."
msgstr ""
#: templates/embroider.inx:9
msgid "Output file format"
msgstr ""
#: templates/embroider.inx:14
msgid "DEBUG"
msgstr ""
#: templates/embroider.inx:17
msgid "Directory"
msgstr ""
#: templates/embroider.inx:17
msgid "Leave empty to save the output in Inkscape's extension directory."
msgstr ""
#: templates/flip.inx:3
msgid "Flip Satin Columns"
msgstr ""
#: templates/input.inx:11
#, python-format
msgid "convert %(file_extension)s file to Ink/Stitch manual-stitch paths"
msgstr ""
#: templates/install.inx:3
msgid "Install add-ons for Inkscape"
msgstr ""
#: templates/layer_commands.inx:3
msgid "Add Layer Commands"
msgstr ""
#: templates/layer_commands.inx:7
msgid "Commands will be added to the currently-selected layer."
msgstr ""
#: templates/object_commands.inx:3
msgid "Attach Commands"
msgstr ""
#: templates/output.inx:11
#, python-format
msgid "Save design in %(file_extension)s format using Ink/Stitch"
msgstr ""
#: templates/params.inx:3
msgid "Params"
msgstr ""
#: templates/simulate.inx:3
msgid "Simulate"
msgstr ""
#: templates/zip.inx:10
msgid "Ink/Stitch: ZIP export multiple formats (.zip)"
msgstr ""
#: templates/zip.inx:11
msgid "Create a ZIP with multiple embroidery file formats using Ink/Stitch"
msgstr ""

Wyświetl plik

@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>{% trans %}Convert Line to Satin{% endtrans %}</name>
<id>org.inkstitch.convert_to_satin</id>
<id>org.inkstitch.convert_to_satin.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="extension" type="string" gui-hidden="true">convert_to_satin</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Ink/Stitch" />
<submenu name="Ink/Stitch">
<submenu name="{% trans %}English{% endtrans %}" />
</submenu>
</effects-menu>
</effect>
<script>

Wyświetl plik

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>{% trans %}Embroider{% endtrans %}</name>
<id>org.inkstitch.embroider</id>
<id>org.inkstitch.embroider.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="collapse_len_mm" type="float" min="0.0" max="10.0" gui-text="{% trans %}Collapse length (mm){% endtrans %}" gui-description="{% trans %}Jump stitches smaller than this will be treated as normal stitches.{% endtrans %}">3.0</param>
<param name="hide_layers" type="boolean" gui-text="{% trans %}Hide other layers{% endtrans %}" gui-description="{% trans %}Hide all other top-level layers when the embroidery layer is generated, in order to make stitching discernible.{% endtrans %}">true</param>
<param name="output_format" type="optiongroup" gui-text="{% trans %}Output file format{% endtrans %}" appearance="minimal">
<param name="collapse_len_mm" type="float" min="0.0" max="10.0" _gui-text="{% trans %}Collapse length (mm){% endtrans %}" _gui-description="{% trans %}Jump stitches smaller than this will be treated as normal stitches.{% endtrans %}">3.0</param>
<param name="hide_layers" type="boolean" _gui-text="{% trans %}Hide other layers{% endtrans %}" _gui-description="{% trans %}Hide all other top-level layers when the embroidery layer is generated, in order to make stitching discernible.{% endtrans %}">true</param>
<param name="output_format" type="optiongroup" _gui-text="{% trans %}Output file format{% endtrans %}" appearance="minimal">
{% for format, description in formats %}
<_option value="{{ format }}">{{ _(description) }} ({{ format | upper }})</_option>
{% endfor %}
@ -14,12 +14,14 @@
<_option value="{{ format }}">{{ _(description) }} ({{ format | upper }}) [{{ _("DEBUG") }}]</_option>
{% endfor %}
</param>
<param name="path" type="string" gui-text="{% trans %}Directory{% endtrans %}" gui-description="{% trans %}Leave empty to save the output in Inkscape's extension directory.{% endtrans %}"></param>
<param name="path" type="string" _gui-text="{% trans %}Directory{% endtrans %}" _gui-description="{% trans %}Leave empty to save the output in Inkscape's extension directory.{% endtrans %}"></param>
<param name="extension" type="string" gui-hidden="true">embroider</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Ink/Stitch"/>
<submenu name="Ink/Stitch">
<submenu name="{% trans %}English{% endtrans %}" />
</submenu>
</effects-menu>
</effect>
<script>

Wyświetl plik

@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>{% trans %}Flip Satin Columns{% endtrans %}</name>
<id>org.inkstitch.flip_satins</id>
<name>{% trans %}Flip Satin Columns{% endtrans %}</_name>
<id>org.inkstitch.flip_satins.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="extension" type="string" gui-hidden="true">flip</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Ink/Stitch"/>
<submenu name="Ink/Stitch">
<submenu name="{% trans %}English{% endtrans %}" />
</submenu>
</effects-menu>
</effect>
<script>

Wyświetl plik

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>{{ format | upper }} file input</name>
<id>org.inkstitch.input.{{ format }}</id>
<name>{{ format | upper }} file input</_name>
<id>org.inkstitch.input.{{ format }}.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<input>

Wyświetl plik

@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>{% trans %}Install add-ons for Inkscape{% endtrans %}</name>
<id>org.inkstitch.install</id>
<name>{% trans %}Install add-ons for Inkscape{% endtrans %}</_name>
<id>org.inkstitch.install.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="extension" type="string" gui-hidden="true">install</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Ink/Stitch"/>
<submenu name="Ink/Stitch">
<submenu name="{% trans %}English{% endtrans %}" />
</submenu>
</effects-menu>
</effect>
<script>

Wyświetl plik

@ -1,19 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>{% trans %}Add Layer Commands{% endtrans %}</name>
<id>org.inkstitch.layer_commands</id>
<name>{% trans %}Add Layer Commands{% endtrans %}</_name>
<id>org.inkstitch.layer_commands.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="description" type="description">{% trans %}Commands will be added to the currently-selected layer.{% endtrans %}</param>
{% for command, description in layer_commands %}
<param name="{{ command }}" type="boolean" gui-text="{{ _(description) }}">false</param>
<param name="{{ command }}" type="boolean" _gui-text="{{ _(description) }}">false</param>
{% endfor %}
<param name="extension" type="string" gui-hidden="true">layer_commands</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Ink/Stitch" />
</effects-menu>
<submenu name="Ink/Stitch">
<submenu name="Ink/Stitch">
<submenu name="{% trans %}English{% endtrans %}" />
</submenu>
</submenu>
</effect>
<script>
<command reldir="extensions" interpreter="python">inkstitch.py</command>

Wyświetl plik

@ -1,17 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>{% trans %}Attach Commands{% endtrans %}</name>
<id>org.inkstitch.commands</id>
<name>{% trans %}Attach Commands{% endtrans %}</_name>
<id>org.inkstitch.commands.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
{% for command, description in object_commands %}
<param name="{{ object }}" type="boolean" gui-text="{{ _(description ) }}">false</param>
<param name="{{ object }}" type="boolean" _gui-text="{{ _(description ) }}">false</param>
{% endfor %}
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Ink/Stitch" />
</effects-menu>
<submenu name="Ink/Stitch">
<submenu name="Ink/Stitch">
<submenu name="{% trans %}English{% endtrans %}" />
</submenu>
</submenu>
</effect>
<script>
<command reldir="extensions" interpreter="python">inkstitch.py</command>

Wyświetl plik

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>{{ format | upper }} file output</name>
<id>org.inkstitch.output.{{ format }}</id>
<name>{{ format | upper }} file output</_name>
<id>org.inkstitch.output.{{ format }}.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<output>

Wyświetl plik

@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>{% trans %}Params{% endtrans %}</name>
<id>org.inkstitch.params</id>
<name>{% trans %}Params{% endtrans %}</_name>
<id>org.inkstitch.params.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="extension" type="string" gui-hidden="true">params</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Ink/Stitch"/>
<submenu name="Ink/Stitch">
<submenu name="{% trans %}English{% endtrans %}" />
</submenu>
</effects-menu>
</effect>
<script>

Wyświetl plik

@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>{% trans %}Print{% endtrans %}</name>
<id>org.inkstitch.print</id>
<name>{% trans %}Print{% endtrans %}</_name>
<id>org.inkstitch.print.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="extension" type="string" gui-hidden="true">print</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Ink/Stitch"/>
<submenu name="Ink/Stitch">
<submenu name="{% trans %}English{% endtrans %}" />
</submenu>
</effects-menu>
</effect>
<script>

Wyświetl plik

@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>{% trans %}Simulate{% endtrans %}</name>
<id>org.inkstitch.simulate</id>
<name>{% trans %}Simulate{% endtrans %}</_name>
<id>org.inkstitch.simulate.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="extension" type="string" gui-hidden="true">simulate</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Ink/Stitch"/>
<submenu name="Ink/Stitch">
<submenu name="{% trans %}English{% endtrans %}" />
</submenu>
</effects-menu>
</effect>
<script>

Wyświetl plik

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>embroidery ZIP file output</name>
<id>org.inkstitch.output.zip</id>
<name>embroidery ZIP file output</_name>
<id>org.inkstitch.output.zip.{{ locale }}</id>
<dependency type="executable" location="extensions">inkstitch.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<output>
@ -12,7 +12,7 @@
<dataloss>true</dataloss>
</output>
{% for format, description in formats %}
<param name="format-{{ format }}" type="boolean" gui-text=".{{ format | upper }}: {{ _(description) }}">false</param>
<param name="format-{{ format }}" type="boolean" _gui-text=".{{ format | upper }}: {{ _(description) }}">false</param>
{% endfor %}
<param name="extension" type="string" gui-hidden="true">zip</param>
<script>