i18n
This commit is contained in:
1 parent
5dc977f9dd
commit
41987f8ea8
17 files changed
+1258
-210
No files matched your search
+37
-7
@@ -7,9 +7,27 @@ pour pouvoir être sélectionnée et déplacée seule.
|
||||
|
||||
import inkex
|
||||
from inkex import Group, PathElement, TextElement
|
||||
from inkex.localization import localize
|
||||
|
||||
import box_core
|
||||
|
||||
# Installe _() dans les builtins : catalogue « box_maker » de la langue de
|
||||
# l'interface (Inkscape transmet domaine et dossier par l'environnement),
|
||||
# textes anglais d'origine sinon.
|
||||
localize()
|
||||
|
||||
|
||||
def panel_names():
|
||||
"""Noms affiches des pieces, indexes par leur nom dans box_core."""
|
||||
return {
|
||||
"Avant": _("Front"),
|
||||
"Arrière": _("Back"),
|
||||
"Gauche": _("Left"),
|
||||
"Droite": _("Right"),
|
||||
"Fond": _("Bottom"),
|
||||
"Couvercle": _("Lid"),
|
||||
}
|
||||
|
||||
|
||||
class BoxMaker(inkex.EffectExtension):
|
||||
def add_arguments(self, pars):
|
||||
@@ -35,8 +53,18 @@ class BoxMaker(inkex.EffectExtension):
|
||||
finger=opt.finger, kerf=opt.kerf,
|
||||
interior=opt.dim_type == "interior", lid=opt.lid, gap=opt.gap,
|
||||
)
|
||||
except ValueError as err:
|
||||
raise inkex.AbortExtension(str(err))
|
||||
except box_core.DimensionTooSmall as err:
|
||||
dimension = {
|
||||
"length": _("length"),
|
||||
"width": _("width"),
|
||||
"height": _("height"),
|
||||
}[err.dimension]
|
||||
inkex.errormsg(_(
|
||||
"The {dimension} ({size:.1f} mm exterior) is too small for the "
|
||||
"thickness ({thickness:g} mm): it must be at least {minimum:g} mm."
|
||||
).format(dimension=dimension, size=err.size, thickness=err.thickness,
|
||||
minimum=err.minimum))
|
||||
return
|
||||
|
||||
mm = self._uu_per_mm()
|
||||
origin_x, origin_y = self._origin(panels, mm)
|
||||
@@ -50,10 +78,12 @@ class BoxMaker(inkex.EffectExtension):
|
||||
"stroke-width": opt.stroke_width * mm,
|
||||
}
|
||||
|
||||
names = panel_names()
|
||||
for panel in panels:
|
||||
name = names[panel.name]
|
||||
path = PathElement()
|
||||
path.set_id(self.svg.get_unique_id("boite-"))
|
||||
path.label = panel.name
|
||||
path.label = name
|
||||
path.style = style
|
||||
path.path = "M " + " L ".join(
|
||||
f"{origin_x + x * mm:.4f},{origin_y + y * mm:.4f}" for x, y in panel.points
|
||||
@@ -62,10 +92,10 @@ class BoxMaker(inkex.EffectExtension):
|
||||
if opt.labels:
|
||||
group = Group()
|
||||
group.set_id(self.svg.get_unique_id("boite-"))
|
||||
group.label = panel.name
|
||||
group.label = name
|
||||
group.transform = to_layer
|
||||
group.add(path)
|
||||
group.add(self._label(panel, origin_x, origin_y, mm))
|
||||
group.add(self._label(panel, name, origin_x, origin_y, mm))
|
||||
layer.add(group)
|
||||
else:
|
||||
path.transform = to_layer
|
||||
@@ -97,7 +127,7 @@ class BoxMaker(inkex.EffectExtension):
|
||||
cx, cy = self.svg.get_page_bbox().center
|
||||
return cx - max_x / 2, cy - max_y / 2
|
||||
|
||||
def _label(self, panel, origin_x, origin_y, mm):
|
||||
def _label(self, panel, name, origin_x, origin_y, mm):
|
||||
min_x, min_y, max_x, max_y = panel.bbox()
|
||||
size = min(5.0, (max_y - min_y) / 4) * mm
|
||||
text = TextElement()
|
||||
@@ -110,7 +140,7 @@ class BoxMaker(inkex.EffectExtension):
|
||||
"fill": "#0000ff",
|
||||
"stroke": "none",
|
||||
}
|
||||
text.text = panel.name
|
||||
text.text = name
|
||||
return text
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user