mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-14 11:21:18 +00:00
* Add orca-translations Claude skill and PO tool
Add a .claude skill that guides translation passes over the localization/i18n gettext catalogs. It covers the workflow: run gettext, settle new glossary terms, translate in batches, verify, and report.
Includes translation-rules.md, which condenses the placeholder, line-break and glossary rules plus the guidance on review notes.
Also adds scripts/po_tool.py (standard library only). It lists pending entries with glossary hints, validates and applies translations, adding '# AI Translated' and '# Needs human review' comments, and rewrites only the entries it changes. It can also check catalogs, look up existing translations, suggest glossary candidates and update the wiki glossary TSV.
* Let po_tool apply translations by entry id
pending now gives each entry a short id, so a translation file can name
entries by id instead of repeating the English msgid. apply accepts either.
A "review": "" item clears an earlier review note when overwriting an
entry, and check gives each msgfmt run its own temporary output file so
parallel checks do not collide.
* Fill all empty translations
Regenerate the template with run_gettext --full and translate every empty
entry in the 22 catalogs (7,089 entries) with the orca-translations skill,
following the localization glossary, including the new belt printer,
IDEX/IQEX and plugin terms. Every new entry is marked "# AI Translated";
122 also carry "# Needs human review" with what to check.
* Show entry ids in po_tool lookup and search translations
lookup now prints each entry's id, so an entry found there can be
rewritten with apply --overwrite without repeating the English, and
--msgstr searches the translations instead of the msgids, which finds
every entry that still uses a term being changed.
SKILL.md describes how to change an established term: check the
catalog's usage first, update the glossary cell, then rewrite only the
entries where the term has that meaning.
* Fix mistranslated terms and align catalogs with the glossary
Correct labels that the glossary had copied, and the entries that used
them:
- ca: Raft was rendered as the Brim term; it is now "Rai". Exhaust fan,
Monotonic line, Unretract, Slice, Lateral Honeycomb and PA Tower
labels fixed.
- cs: Lightning infill is "Blesk", not "Osvětlení" (illumination).
- sv: Retraction is "Retraktion", not "Reduktion"; Unretract,
Lagerhöjd, Delkylningsfläkt, Utsugsfläkt, Aligned Rectilinear and the
Preset label fixed.
- de: Brim is "Rand" and Skirt is "Umrandung", as most entries already
had them.
- lt: brim entries used the Skirt word "apvadas"; they now use "kraštas".
- es: Sparse infill is "relleno de baja densidad", the catalog majority.
- eu: nozzle wipe is "garbiketa", not purge.
- th: the project plate is "เพลต", distinct from the bed.
- uk: Quarter Cubic, Latin "PA" in PA Tower, and Belt purge tower.
- pl: Cross Hatch, Tri-hexagon, Volumetric speed and Raft labels.
- zh_TW: Brim stays "Brim", as the existing labels have it.
- tr: "Prime Tower" read "Prime Minister Tower".
- ko: the plugin "Capabilities" label read "performance".
- Build Volume labels fixed in tr, de, cs and eu.
All 242 rewritten entries are marked "# AI Translated".
* Make more UI text translatable and fix pluralization and context
Audit the sources for text that translators could not translate
correctly and fix it.
Mark text that reached users in English only: IDEX/IQEX role names,
plugin permission prompts and errors, 3MF/preset loading errors, G-code
placeholder parser errors, calibration and device messages, notification
texts, file dialog filters, and the config validation messages.
Replace sentences built from translated fragments, such as the prime
tower warnings, "left"/"right" nozzle names, and "Filament " + number,
with single msgids that have placeholders, so translators can reorder
and inflect them.
Use plural forms for texts with a count ("%1% mixed filaments",
"%d objects", "%1% triangles") instead of "(s)" and mismatched verbs.
Fix the swapped singular/plural pair in "The following presets inherit
this preset".
Add translation contexts where one English word has several meanings
(Subscribed/Local, Standard, Pause, View, Step, Model, Camera, Flow,
Filter, Others, Prepare, the Design tools). Show "Size" instead of
"Build Volume" in the Cut tool, which displays the object size.
Fix code that compared translated text with English (the Edit G-code
dialog group, the plugin registration failure check), and add the
bundled web pages' missing string-table entries. Use the single
character for degrees Celsius, say "G-code", and describe the head
filament map without internal jargon.
Install the libslic3r translate callback before the presets load, so
their load errors are translated, and list the 28 source files that had
marked strings but were never extracted into localization/i18n/list.txt.
* Suggest earlier translations and list fuzzy entries in po_tool pending
pending now attaches the closest earlier translation of a similar
English text (from obsolete or translated entries), so a reworded or
split string keeps its wording, and it lists fuzzy entries by default,
since users never see them. A fuzzy entry also carries its stale
translation as previous_translation.
* Fix wording of the non-boolean operands error
The logical operation error said "operators" where it means the
operands the operation was applied to.
* Translate the newly translatable strings in all languages
Regenerate the template after the translatability changes and fill every
new or changed entry in the 22 catalogs (about 12,800 entries): the
strings that became translatable, the plural forms, the entries split by
context, and the previously fuzzy singular entries that became plurals.
Every new entry is marked "# AI Translated", and about 360 also carry a
"# Needs human review" note saying what to check. Terms follow the
localization glossary. Earlier translations of reworded strings were
reused where the meaning was unchanged. Existing entries were not
changed, and obsolete entries are kept.
* Document the source translatability audit in the orca-translations skill
Add a reference describing how strings reach translators, what to look
for (untranslated text, spliced sentences, missing plurals, ambiguous
words), what not to translate, where a context cannot be carried, and
what to do after the edits, plus a scanner that lists untranslated
user-facing string literals.
* Document how to write translatable strings in AGENTS.md
Tell developers to keep each message complete in one msgid: use
placeholders instead of concatenating translated fragments, plural forms
for counts, and contexts for ambiguous words, and to list new source
files in localization/i18n/list.txt. Add a matching code review item.
* Translate the strings added since the rebase
Regenerate the template against the current main and translate the 26
new entries per language: the Fix Model commands and messages, and the
texture displacement image adjustment panel. Each new entry is marked
"# AI Translated"; existing entries are unchanged.
* tidy
281 lines
12 KiB
C++
281 lines
12 KiB
C++
#include "Flow.hpp"
|
|
#include "Exception.hpp"
|
|
#include "Config.hpp"
|
|
#include "Print.hpp"
|
|
#include "libslic3r.h"
|
|
#include <cmath>
|
|
#include <assert.h>
|
|
|
|
#include <boost/algorithm/string/predicate.hpp>
|
|
#include <string>
|
|
#include <math.h>
|
|
#include "PrintConfig.hpp"
|
|
#include "I18N.hpp"
|
|
|
|
// Mark string for localization and translate.
|
|
#define L(s) Slic3r::I18N::translate(s)
|
|
|
|
namespace Slic3r {
|
|
|
|
FlowErrorNegativeSpacing::FlowErrorNegativeSpacing() :
|
|
FlowError(L("Flow::spacing() produced negative spacing. Did you set some extrusion width too small?")) {}
|
|
|
|
FlowErrorNegativeFlow::FlowErrorNegativeFlow() :
|
|
FlowError(L("Flow::mm3_per_mm() produced negative flow. Did you set some extrusion width too small?")) {}
|
|
|
|
// This static method returns a sane extrusion width default.
|
|
float Flow::auto_extrusion_width(FlowRole role, float nozzle_diameter)
|
|
{
|
|
switch (role) {
|
|
case frSupportMaterial:
|
|
case frSupportMaterialInterface:
|
|
case frSupportTransition:
|
|
case frTopSolidInfill:
|
|
return nozzle_diameter;
|
|
default:
|
|
case frExternalPerimeter:
|
|
case frPerimeter:
|
|
case frSolidInfill:
|
|
case frInfill:
|
|
return 1.125f * nozzle_diameter;
|
|
}
|
|
}
|
|
|
|
// Used by the Flow::extrusion_width() funtion to provide hints to the user on default extrusion width values,
|
|
// and to provide reasonable values to the PlaceholderParser.
|
|
static inline FlowRole opt_key_to_flow_role(const std::string &opt_key)
|
|
{
|
|
if (opt_key == "inner_wall_line_width" ||
|
|
// or all the defaults:
|
|
opt_key == "line_width" || opt_key == "initial_layer_line_width")
|
|
return frPerimeter;
|
|
else if (opt_key == "outer_wall_line_width")
|
|
return frExternalPerimeter;
|
|
else if (opt_key == "sparse_infill_line_width")
|
|
return frInfill;
|
|
else if (opt_key == "internal_solid_infill_line_width")
|
|
return frSolidInfill;
|
|
else if (opt_key == "bridge_line_width")
|
|
return frSolidInfill;
|
|
else if (opt_key == "top_surface_line_width")
|
|
return frTopSolidInfill;
|
|
else if (opt_key == "support_line_width")
|
|
return frSupportMaterial;
|
|
else
|
|
throw Slic3r::RuntimeError("opt_key_to_flow_role: invalid argument");
|
|
};
|
|
|
|
static inline void throw_on_missing_variable(const std::string &opt_key, const char *dependent_opt_key)
|
|
{
|
|
// TRN %1% and %2% are names of settings.
|
|
throw FlowErrorMissingVariable((boost::format(L("Failed to calculate line width of %1%. Cannot get value of \"%2%\".")) % opt_key % dependent_opt_key).str());
|
|
}
|
|
|
|
// Used to provide hints to the user on default extrusion width values, and to provide reasonable values to the PlaceholderParser.
|
|
double Flow::extrusion_width(const std::string& opt_key, const ConfigOptionFloatOrPercent* opt, const ConfigOptionResolver& config, const unsigned int first_printing_extruder)
|
|
{
|
|
assert(opt != nullptr);
|
|
|
|
auto opt_nozzle_diameters = config.option<ConfigOptionFloats>("nozzle_diameter");
|
|
if (opt_nozzle_diameters == nullptr)
|
|
throw_on_missing_variable(opt_key, "nozzle_diameter");
|
|
const float nozzle_diameter = float(opt_nozzle_diameters->get_at(first_printing_extruder));
|
|
|
|
if (opt_key == "bridge_line_width") {
|
|
if (opt->percent) {
|
|
const double bridge_width = opt->get_abs_value(nozzle_diameter);
|
|
if (bridge_width > 0.)
|
|
return bridge_width;
|
|
} else if (opt->value > 0.) {
|
|
return opt->value;
|
|
}
|
|
|
|
opt = config.option<ConfigOptionFloatOrPercent>("internal_solid_infill_line_width");
|
|
if (opt == nullptr)
|
|
throw_on_missing_variable(opt_key, "internal_solid_infill_line_width");
|
|
return extrusion_width("internal_solid_infill_line_width", opt, config, first_printing_extruder);
|
|
}
|
|
|
|
#if 0
|
|
// This is the logic used for skit / brim, but not for the rest of the 1st layer.
|
|
if (opt->value == 0. && first_layer) {
|
|
// The "initial_layer_line_width" was set to zero, try a substitute.
|
|
opt = config.option<ConfigOptionFloatOrPercent>("inner_wall_line_width");
|
|
if (opt == nullptr)
|
|
throw_on_missing_variable(opt_key, "inner_wall_line_width");
|
|
}
|
|
#endif
|
|
|
|
if (opt->value == 0.) {
|
|
// The role specific extrusion width value was set to zero, try the role non-specific extrusion width.
|
|
opt = config.option<ConfigOptionFloatOrPercent>("line_width");
|
|
if (opt == nullptr)
|
|
throw_on_missing_variable(opt_key, "line_width");
|
|
}
|
|
|
|
if (opt->percent) {
|
|
return opt->get_abs_value(nozzle_diameter);
|
|
}
|
|
|
|
if (opt->value == 0.) {
|
|
// If user left option to 0, calculate a sane default width.
|
|
return auto_extrusion_width(opt_key_to_flow_role(opt_key), nozzle_diameter);
|
|
}
|
|
|
|
return opt->value;
|
|
}
|
|
|
|
// Used to provide hints to the user on default extrusion width values, and to provide reasonable values to the PlaceholderParser.
|
|
double Flow::extrusion_width(const std::string& opt_key, const ConfigOptionResolver &config, const unsigned int first_printing_extruder)
|
|
{
|
|
return extrusion_width(opt_key, config.option<ConfigOptionFloatOrPercent>(opt_key), config, first_printing_extruder);
|
|
}
|
|
|
|
// This constructor builds a Flow object from an extrusion width config setting
|
|
// and other context properties.
|
|
Flow Flow::new_from_config_width(FlowRole role, const ConfigOptionFloatOrPercent &width, float nozzle_diameter, float height)
|
|
{
|
|
if (height <= 0)
|
|
throw Slic3r::InvalidArgument("Invalid flow height supplied to new_from_config_width().");
|
|
|
|
float w;
|
|
if (!width.percent && width.value <= 0.) {
|
|
// If user left option to 0, calculate a sane default width.
|
|
w = auto_extrusion_width(role, nozzle_diameter);
|
|
} else {
|
|
// If user set a manual value, use it.
|
|
w = float(width.get_abs_value(nozzle_diameter));
|
|
}
|
|
|
|
return Flow(w, height, rounded_rectangle_extrusion_spacing(w, height), nozzle_diameter, false);
|
|
}
|
|
|
|
// Adjust extrusion flow for new extrusion line spacing, maintaining the old spacing between extrusions.
|
|
Flow Flow::with_spacing(float new_spacing) const
|
|
{
|
|
Flow out = *this;
|
|
if (m_bridge) {
|
|
// Diameter of the rounded extrusion.
|
|
assert(m_width == m_height);
|
|
float gap = m_spacing - m_width;
|
|
auto new_diameter = new_spacing - gap;
|
|
out.m_width = out.m_height = new_diameter;
|
|
} else {
|
|
assert(m_width >= m_height);
|
|
out.m_width += new_spacing - m_spacing;
|
|
if (out.m_width < out.m_height)
|
|
throw Slic3r::InvalidArgument(L("Invalid spacing supplied to Flow::with_spacing(), check your layer height and extrusion width."));
|
|
}
|
|
out.m_spacing = new_spacing;
|
|
return out;
|
|
}
|
|
|
|
// Adjust the width / height of a rounded extrusion model to reach the prescribed cross section area while maintaining extrusion spacing.
|
|
Flow Flow::with_cross_section(float area_new) const
|
|
{
|
|
assert(! m_bridge);
|
|
assert(m_width >= m_height);
|
|
|
|
// Adjust for bridge_flow, maintain the extrusion spacing.
|
|
float area = this->mm3_per_mm();
|
|
if (area_new > area + EPSILON) {
|
|
// Increasing the flow rate.
|
|
float new_full_spacing = area_new / m_height;
|
|
if (new_full_spacing > m_spacing) {
|
|
// Filling up the spacing without an air gap. Grow the extrusion in height.
|
|
float height = area_new / m_spacing;
|
|
return Flow(rounded_rectangle_extrusion_width_from_spacing(m_spacing, height), height, m_spacing, m_nozzle_diameter, false);
|
|
} else {
|
|
return this->with_width(rounded_rectangle_extrusion_width_from_spacing(area / m_height, m_height));
|
|
}
|
|
} else if (area_new < area - EPSILON) {
|
|
// Decreasing the flow rate.
|
|
float width_new = m_width - (area - area_new) / m_height;
|
|
assert(width_new > 0);
|
|
if (width_new > m_height) {
|
|
// Shrink the extrusion width.
|
|
return this->with_width(width_new);
|
|
} else {
|
|
// Create a rounded extrusion.
|
|
auto dmr = float(sqrt(area_new / M_PI));
|
|
return Flow(dmr, dmr, m_spacing, m_nozzle_diameter, false);
|
|
}
|
|
} else
|
|
return *this;
|
|
}
|
|
|
|
float Flow::rounded_rectangle_extrusion_spacing(float width, float height)
|
|
{
|
|
auto out = width - height * float(1. - 0.25 * PI);
|
|
if (out <= 0.f)
|
|
throw FlowErrorNegativeSpacing();
|
|
return out;
|
|
}
|
|
|
|
float Flow::rounded_rectangle_extrusion_width_from_spacing(float spacing, float height)
|
|
{
|
|
return float(spacing + height * (1. - 0.25 * PI));
|
|
}
|
|
|
|
float Flow::bridge_extrusion_spacing(float dmr)
|
|
{
|
|
return dmr + BRIDGE_EXTRA_SPACING;
|
|
}
|
|
|
|
// This method returns extrusion volume per head move unit.
|
|
double Flow::mm3_per_mm() const
|
|
{
|
|
float res = m_bridge ?
|
|
// Area of a circle with dmr of this->width.
|
|
float((m_width * m_width) * 0.25 * PI) :
|
|
// Rectangle with semicircles at the ends. ~ h (w - 0.215 h)
|
|
float(m_height * (m_width - m_height * (1. - 0.25 * PI)));
|
|
//assert(res > 0.);
|
|
if (res <= 0.)
|
|
throw FlowErrorNegativeFlow();
|
|
return res;
|
|
}
|
|
|
|
Flow support_material_flow(const PrintObject *object, float layer_height)
|
|
{
|
|
return Flow::new_from_config_width(
|
|
frSupportMaterial,
|
|
// The width parameter accepted by new_from_config_width is of type ConfigOptionFloatOrPercent, the Flow class takes care of the percent to value substitution.
|
|
(object->config().support_line_width.value > 0) ? object->config().support_line_width : object->config().line_width,
|
|
// if object->config().support_filament == 0 (which means to not trigger tool change, but use the current extruder instead), get_at will return the 0th component.
|
|
float(nozzle_diameter_for_filament(object->print()->config(), object->config().support_filament, object->print()->is_BBL_printer())),
|
|
(layer_height > 0.f) ? layer_height : float(object->config().layer_height.value));
|
|
}
|
|
//BBS
|
|
Flow support_transition_flow(const PrintObject* object)
|
|
{
|
|
//BBS: support transition of tree support is bridge flow
|
|
float dmr = float(nozzle_diameter_for_filament(object->print()->config(), object->config().support_filament, object->print()->is_BBL_printer()));
|
|
return Flow::bridging_flow(dmr, dmr);
|
|
}
|
|
|
|
Flow support_material_1st_layer_flow(const PrintObject *object, float layer_height)
|
|
{
|
|
const PrintConfig &print_config = object->print()->config();
|
|
const auto &width = (print_config.initial_layer_line_width.value > 0) ? print_config.initial_layer_line_width : object->config().support_line_width;
|
|
return Flow::new_from_config_width(
|
|
frSupportMaterial,
|
|
// The width parameter accepted by new_from_config_width is of type ConfigOptionFloatOrPercent, the Flow class takes care of the percent to value substitution.
|
|
(width.value > 0) ? width : object->config().line_width,
|
|
float(nozzle_diameter_for_filament(print_config, object->config().support_filament, object->print()->is_BBL_printer())),
|
|
(layer_height > 0.f) ? layer_height : float(print_config.initial_layer_print_height.value));
|
|
}
|
|
|
|
Flow support_material_interface_flow(const PrintObject *object, float layer_height)
|
|
{
|
|
return Flow::new_from_config_width(
|
|
frSupportMaterialInterface,
|
|
// The width parameter accepted by new_from_config_width is of type ConfigOptionFloatOrPercent, the Flow class takes care of the percent to value substitution.
|
|
(object->config().support_line_width > 0) ? object->config().support_line_width : object->config().line_width,
|
|
// if object->config().support_interface_filament == 0 (which means to not trigger tool change, but use the current extruder instead), get_at will return the 0th component.
|
|
float(nozzle_diameter_for_filament(object->print()->config(), object->config().support_interface_filament, object->print()->is_BBL_printer())),
|
|
(layer_height > 0.f) ? layer_height : float(object->config().layer_height.value));
|
|
}
|
|
|
|
}
|