add tiles json and internationalization

pull/1803/head
Lex Neva 2023-02-18 22:24:58 -05:00
rodzic 315866de9a
commit d278f6a54a
154 zmienionych plików z 420 dodań i 14 usunięć

Wyświetl plik

@ -19,11 +19,12 @@ messages.po: inx
sed -i 's/charset=CHARSET/charset=UTF-8/g' messages-inx.po sed -i 's/charset=CHARSET/charset=UTF-8/g' messages-inx.po
bin/pyembroidery-gettext > pyembroidery-format-descriptions.py bin/pyembroidery-gettext > pyembroidery-format-descriptions.py
bin/inkstitch-fonts-gettext > inkstitch-fonts-metadata.py bin/inkstitch-fonts-gettext > inkstitch-fonts-metadata.py
bin/inkstitch-tiles-gettext > inkstitch-tiles-metadata.py
# After the inx files are finished building, we don't need the src/ folder anymore. # After the inx files are finished building, we don't need the src/ folder anymore.
# We don't want babel to grab possible translation strings from that folder, so let's remove it # We don't want babel to grab possible translation strings from that folder, so let's remove it
rm -rf src/ rm -rf src/
pybabel extract -o messages-babel.po -F babel.conf --add-location=full --add-comments=l10n,L10n,L10N --sort-by-file --strip-comments -k N_ -k '$$gettext' . pybabel extract -o messages-babel.po -F babel.conf --add-location=full --add-comments=l10n,L10n,L10N --sort-by-file --strip-comments -k N_ -k '$$gettext' .
rm pyembroidery-format-descriptions.py inkstitch-fonts-metadata.py rm pyembroidery-format-descriptions.py inkstitch-fonts-metadata.py inkstitch-tiles-metadata.py
cd electron && yarn --link-duplicates --pure-lockfile cd electron && yarn --link-duplicates --pure-lockfile
find electron/src -name '*.html' -o -name '*.js' -o -name '*.vue' | xargs electron/node_modules/.bin/gettext-extract --quiet --attribute v-translate --output messages-vue.po find electron/src -name '*.html' -o -name '*.js' -o -name '*.vue' | xargs electron/node_modules/.bin/gettext-extract --quiet --attribute v-translate --output messages-vue.po
msgcat -o messages.po messages-babel.po messages-vue.po messages-inx.po msgcat -o messages.po messages-babel.po messages-vue.po messages-inx.po

Wyświetl plik

@ -0,0 +1,21 @@
#!/usr/bin/env python
import os
import json
# generate fake python code containing the names and descriptions of all built-
# in tiles as gettext calls so that pybabel will extract them into messages.po
tiles_dir = os.path.join(os.path.dirname(__file__), "..", "tiles")
for tile in sorted(os.listdir(tiles_dir)):
with open(os.path.join(tiles_dir, tile, "tile.json")) as tile_json:
tile_metadata = json.load(tile_json)
print("# L10N name of tile in tiles/%s" % tile)
print("_(%s)" % repr(tile_metadata.get("name", "")))
if tile_metadata.get("description", ""):
print("# L10N description of tile in tiles/%s" % tile)
print("_(%s)" % repr(tile_metadata.get("description", "")))

Wyświetl plik

@ -33,11 +33,11 @@ def meander_fill(fill, shape, shape_index, starting_point, ending_point):
return post_process(generate_meander_path(graph, start, end, rng), shape, fill) return post_process(generate_meander_path(graph, start, end, rng), shape, fill)
def get_tile(tile_name): def get_tile(tile_id):
all_tiles = {tile.name: tile for tile in tiles.all_tiles()} all_tiles = {tile.id: tile for tile in tiles.all_tiles()}
try: try:
return all_tiles.get(tile_name, all_tiles.popitem()[1]) return all_tiles.get(tile_id, all_tiles.popitem()[1])
except KeyError: except KeyError:
return None return None

Wyświetl plik

@ -2,12 +2,14 @@ import os
from math import ceil, floor from math import ceil, floor
import inkex import inkex
import json
import lxml import lxml
import networkx as nx import networkx as nx
from shapely.geometry import LineString from shapely.geometry import LineString
from shapely.prepared import prep from shapely.prepared import prep
from .debug import debug from .debug import debug
from .i18n import _
from .svg import apply_transforms from .svg import apply_transforms
from .utils import Point, cache, get_bundled_dir, guess_inkscape_config_path from .utils import Point, cache, get_bundled_dir, guess_inkscape_config_path
from .utils.threading import check_stop_flag from .utils.threading import check_stop_flag
@ -18,10 +20,8 @@ class Tile:
self._load_tile(path) self._load_tile(path)
def _load_tile(self, tile_path): def _load_tile(self, tile_path):
self.tile_svg = inkex.load_svg(tile_path) self.tile_svg = inkex.load_svg(os.path.join(tile_path, "tile.svg"))
self.tile_path = tile_path self._load_metadata(tile_path)
self.id = self._get_name(tile_path)
self.name = self.id
self.tile = None self.tile = None
self.width = None self.width = None
self.height = None self.height = None
@ -32,10 +32,16 @@ class Tile:
return self.name < other.name return self.name < other.name
def __repr__(self): def __repr__(self):
return f"Tile({self.name}, {self.shift0}, {self.shift1})" return f"Tile({self.name}, {self.id})"
__str__ = __repr__ __str__ = __repr__
def _load_metadata(self, tile_path):
with open(os.path.join(tile_path, "tile.json"), "rb") as tile_json:
tile_metadata = json.load(tile_json)
self.name = _(tile_metadata.get('name'))
self.id = tile_metadata.get('id')
def _get_name(self, tile_path): def _get_name(self, tile_path):
return os.path.splitext(os.path.basename(tile_path))[0] return os.path.splitext(os.path.basename(tile_path))[0]
@ -166,13 +172,16 @@ def all_tile_paths():
@cache @cache
def all_tiles(): def all_tiles():
tiles = [] tiles = []
for tile_dir in all_tile_paths(): for tiles_path in all_tile_paths():
try: try:
for tile_file in sorted(os.listdir(tile_dir)): for tile_dir in sorted(os.listdir(tiles_path)):
try: try:
tiles.append(Tile(os.path.join(tile_dir, tile_file))) tiles.append(Tile(os.path.join(tiles_path, tile_dir)))
except (OSError, lxml.etree.XMLSyntaxError): except (OSError, lxml.etree.XMLSyntaxError, json.JSONDecodeError, KeyError) as exc:
pass debug.log(f"error loading tile {tiles_path}/{tile_dir}: {exc}")
except Exception as exc:
debug.log(f"unexpected error loading tile {tiles_path}/{tile_dir}: {exc}")
raise
except FileNotFoundError: except FileNotFoundError:
pass pass

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-11a",
"name": "N3-11a",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.7 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.7 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-12",
"name": "N3-12",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-16a",
"name": "N3-16a",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-17",
"name": "N3-17",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.0 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.0 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-18-modified",
"name": "N3-18-modified",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.3 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.3 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-18",
"name": "N3-18",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.3 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.3 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-20",
"name": "N3-20",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.5 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.5 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-23b",
"name": "N3-23b",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.6 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.6 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-25c",
"name": "N3-25c",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.6 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.6 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-26b",
"name": "N3-26b",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.8 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-27",
"name": "N3-27",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.9 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.9 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-30a",
"name": "N3-30a",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 5.3 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.3 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-51b",
"name": "N3-51b",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.3 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.3 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-57f-modified",
"name": "N3-57f-modified",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-58b",
"name": "N3-58b",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 5.0 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.0 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-6",
"name": "N3-6",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.3 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.3 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-7",
"name": "N3-7",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-8a-modified",
"name": "N3-8a-modified",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 1.6 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.6 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-8a",
"name": "N3-8a",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.0 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.0 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N3-8b",
"name": "N3-8b",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-13b",
"name": "N4-13b",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.6 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.6 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-13c",
"name": "N4-13c",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.5 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.5 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-13d",
"name": "N4-13d",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 5.5 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.5 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-13e",
"name": "N4-13e",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.2 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.2 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-13f",
"name": "N4-13f",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.6 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.6 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-16a",
"name": "N4-16a",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.6 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.6 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-19",
"name": "N4-19",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.0 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.0 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-20",
"name": "N4-20",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 5.2 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.2 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-21c",
"name": "N4-21c",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.6 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.6 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-22",
"name": "N4-22",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.8 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-23a",
"name": "N4-23a",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 5.5 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.5 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-23c",
"name": "N4-23c",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.8 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-27",
"name": "N4-27",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.7 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.7 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-29e",
"name": "N4-29e",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.1 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.1 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-29f",
"name": "N4-29f",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.9 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.9 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-31",
"name": "N4-31",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.7 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.7 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-38",
"name": "N4-38",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 5.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.8 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-42e",
"name": "N4-42e",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.2 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.2 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-44",
"name": "N4-44",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.2 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.2 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-52",
"name": "N4-52",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.2 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.2 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-54d",
"name": "N4-54d",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.2 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.2 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-5a-2",
"name": "N4-5a-2",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.6 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.6 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-5a",
"name": "N4-5a",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.8 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-82",
"name": "N4-82",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.3 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.3 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N4-85d",
"name": "N4-85d",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.6 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.6 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N5-1e1",
"name": "N5-1e1",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.8 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N5-1q2",
"name": "N5-1q2",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.7 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.7 KiB

Wyświetl plik

@ -0,0 +1,5 @@
{
"id": "N5-1t",
"name": "N5-1t",
"description": ""
}

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.5 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.5 KiB

Some files were not shown because too many files have changed in this diff Show More