i18n
This commit is contained in:
1 parent
5dc977f9dd
commit
41987f8ea8
17 files changed
+1258
-210
No files matched your search
+23
-5
@@ -33,6 +33,27 @@ class Panel:
|
||||
return Panel(self.name, [(x + dx, y + dy) for x, y in self.points])
|
||||
|
||||
|
||||
_DIMENSION_NAMES = {"length": "longueur", "width": "largeur", "height": "hauteur"}
|
||||
|
||||
|
||||
class DimensionTooSmall(ValueError):
|
||||
"""Dimension exterieure trop petite pour l'epaisseur.
|
||||
|
||||
Les champs (dimension = "length" | "width" | "height", size, thickness,
|
||||
minimum) permettent a l'extension de traduire le message.
|
||||
"""
|
||||
|
||||
def __init__(self, dimension, size, thickness):
|
||||
self.dimension = dimension
|
||||
self.size = size
|
||||
self.thickness = thickness
|
||||
self.minimum = 5 * thickness
|
||||
super().__init__(
|
||||
f"La {_DIMENSION_NAMES[dimension]} ({size:.1f} mm extérieure) est trop petite "
|
||||
f"pour l'épaisseur ({thickness:g} mm) : il faut au moins {self.minimum:g} mm."
|
||||
)
|
||||
|
||||
|
||||
def finger_count(middle, finger):
|
||||
"""Nombre impair (≥ 3) de créneaux sur une longueur utile `middle`."""
|
||||
n = max(1, round(middle / finger))
|
||||
@@ -119,13 +140,10 @@ def box_panels(length, width, height, thickness, finger=0.0, interior=False, lid
|
||||
width += 2 * t
|
||||
height += 2 * t if lid else t
|
||||
|
||||
for label, size in (("longueur", length), ("largeur", width), ("hauteur", height)):
|
||||
for dimension, size in (("length", length), ("width", width), ("height", height)):
|
||||
middle = size - 2 * t
|
||||
if middle <= 0 or middle / finger_count(middle, finger) < t:
|
||||
raise ValueError(
|
||||
f"La {label} ({size:.1f} mm extérieure) est trop petite pour "
|
||||
f"l'épaisseur ({t:g} mm) : il faut au moins {5 * t:g} mm."
|
||||
)
|
||||
raise DimensionTooSmall(dimension, size, t)
|
||||
|
||||
top = MALE if lid else PLAIN
|
||||
front = (top, MALE, MALE, MALE)
|
||||
|
||||
Reference in new issue
Block a user