mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-18 05:00:55 +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
247 lines
7.1 KiB
C++
247 lines
7.1 KiB
C++
#include "Extruder.hpp"
|
|
#include "Exception.hpp"
|
|
#include "PrintConfig.hpp"
|
|
#include <vector>
|
|
#include "libslic3r.h"
|
|
#include <cassert>
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
#include "Config.hpp"
|
|
#include "I18N.hpp"
|
|
|
|
namespace Slic3r {
|
|
|
|
std::vector<double> Extruder::m_share_E = std::vector<double>(MAXIMUM_EXTRUDER_NUMBER, 0);
|
|
std::vector<double> Extruder::m_share_retracted = std::vector<double>(MAXIMUM_EXTRUDER_NUMBER, 0);
|
|
|
|
Extruder::Extruder(unsigned int id, GCodeConfig *config, bool share_extruder) :
|
|
m_id(id),
|
|
m_config(config),
|
|
m_share_extruder(share_extruder)
|
|
{
|
|
reset();
|
|
|
|
m_config_index = int(m_id);
|
|
// cache values that are going to be called often
|
|
m_e_per_mm3 = this->filament_flow_ratio();
|
|
m_e_per_mm3 /= this->filament_crossection();
|
|
}
|
|
|
|
void Extruder::set_config_index(int idx)
|
|
{
|
|
m_config_index = idx < 0 ? int(m_id) : idx;
|
|
// keep the cached flow term reading the same column as the getters
|
|
m_e_per_mm3 = this->filament_flow_ratio();
|
|
m_e_per_mm3 /= this->filament_crossection();
|
|
}
|
|
|
|
unsigned int Extruder::extruder_id() const
|
|
{
|
|
assert(m_config);
|
|
if (m_id < m_config->filament_map.size()) {
|
|
return m_config->filament_map.get_at(m_id) - 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
double Extruder::extrude(double dE)
|
|
{
|
|
// BBS
|
|
if (m_share_extruder) {
|
|
if (m_config->use_relative_e_distances)
|
|
m_share_E[extruder_id()] = 0.;
|
|
m_share_E[extruder_id()] += dE;
|
|
m_absolute_E += dE;
|
|
if (dE < 0.)
|
|
m_share_retracted[extruder_id()] -= dE;
|
|
} else {
|
|
// in case of relative E distances we always reset to 0 before any output
|
|
if (m_config->use_relative_e_distances)
|
|
m_E = 0.;
|
|
m_E += dE;
|
|
m_absolute_E += dE;
|
|
if (dE < 0.)
|
|
m_retracted -= dE;
|
|
}
|
|
return dE;
|
|
}
|
|
|
|
/* This method makes sure the extruder is retracted by the specified amount
|
|
of filament and returns the amount of filament retracted.
|
|
If the extruder is already retracted by the same or a greater amount,
|
|
this method is a no-op.
|
|
The restart_extra argument sets the extra length to be used for
|
|
unretraction. If we're actually performing a retraction, any restart_extra
|
|
value supplied will overwrite the previous one if any. */
|
|
double Extruder::retract(double length, double restart_extra)
|
|
{
|
|
// BBS
|
|
if (m_share_extruder) {
|
|
if (m_config->use_relative_e_distances)
|
|
m_share_E[extruder_id()] = 0.;
|
|
double to_retract = std::max(0., length - m_share_retracted[extruder_id()]);
|
|
m_restart_extra = restart_extra;
|
|
if (to_retract > 0.) {
|
|
m_share_E[extruder_id()] -= to_retract;
|
|
m_absolute_E -= to_retract;
|
|
m_share_retracted[extruder_id()] += to_retract;
|
|
}
|
|
return to_retract;
|
|
} else {
|
|
// in case of relative E distances we always reset to 0 before any output
|
|
if (m_config->use_relative_e_distances)
|
|
m_E = 0.;
|
|
double to_retract = std::max(0., length - m_retracted);
|
|
m_restart_extra = restart_extra;
|
|
if (to_retract > 0.) {
|
|
m_E -= to_retract;
|
|
m_absolute_E -= to_retract;
|
|
m_retracted += to_retract;
|
|
}
|
|
return to_retract;
|
|
}
|
|
}
|
|
|
|
double Extruder::unretract()
|
|
{
|
|
// BBS
|
|
if (m_share_extruder) {
|
|
double dE = m_share_retracted[extruder_id()] + m_restart_extra;
|
|
this->extrude(dE);
|
|
m_share_retracted[extruder_id()] = 0.;
|
|
m_restart_extra = 0.;
|
|
return dE;
|
|
} else {
|
|
double dE = m_retracted + m_restart_extra;
|
|
this->extrude(dE);
|
|
m_retracted = 0.;
|
|
m_restart_extra = 0.;
|
|
return dE;
|
|
}
|
|
}
|
|
|
|
// Setting the retract state from the script.
|
|
// Sets current retraction value & restart extra filament amount if retracted > 0.
|
|
void Extruder::set_retracted(double retracted, double restart_extra)
|
|
{
|
|
if (retracted < - EPSILON)
|
|
throw Slic3r::RuntimeError(_u8L("Custom G-code reports negative z_retracted."));
|
|
if (restart_extra < - EPSILON)
|
|
throw Slic3r::RuntimeError(_u8L("Custom G-code reports negative z_restart_extra."));
|
|
|
|
if (retracted > EPSILON) {
|
|
m_retracted = retracted;
|
|
m_restart_extra = restart_extra < EPSILON ? 0 : restart_extra;
|
|
} else {
|
|
m_retracted = 0;
|
|
m_restart_extra = 0;
|
|
}
|
|
}
|
|
|
|
// Used filament volume in mm^3.
|
|
double Extruder::extruded_volume() const
|
|
{
|
|
// BBS
|
|
if (m_share_extruder) {
|
|
// FIXME: need to count m_retracted for share extruder machine
|
|
return this->used_filament() * this->filament_crossection();
|
|
} else {
|
|
return this->used_filament() * this->filament_crossection();
|
|
}
|
|
}
|
|
|
|
// Used filament length in mm.
|
|
double Extruder::used_filament() const
|
|
{
|
|
// BBS
|
|
if (m_share_extruder) {
|
|
// FIXME: need to count retracted length for share-extruder machine
|
|
return m_absolute_E;
|
|
} else {
|
|
return m_absolute_E + m_retracted;
|
|
}
|
|
}
|
|
|
|
double Extruder::filament_diameter() const
|
|
{
|
|
return m_config->filament_diameter.get_at(m_id);
|
|
}
|
|
|
|
double Extruder::filament_density() const
|
|
{
|
|
return m_config->filament_density.get_at(m_id);
|
|
}
|
|
|
|
double Extruder::filament_cost() const
|
|
{
|
|
return m_config->filament_cost.get_at(m_id);
|
|
}
|
|
|
|
double Extruder::filament_flow_ratio() const
|
|
{
|
|
return m_config->filament_flow_ratio.get_at(m_config_index);
|
|
}
|
|
|
|
// Return a "retract_before_wipe" percentage as a factor clamped to <0, 1>
|
|
double Extruder::retract_before_wipe() const
|
|
{
|
|
return std::clamp(m_config->retract_before_wipe.get_at(m_config_index) * 0.01, 0., 1.);
|
|
}
|
|
|
|
// Orca:
|
|
// Return a "retract_after_wipe" percentage as a factor clamped to <0, 1>
|
|
double Extruder::retract_after_wipe() const
|
|
{
|
|
return std::min(std::clamp(m_config->retract_after_wipe.get_at(m_config_index) * 0.01, 0., 1.), 1. - retract_before_wipe());
|
|
}
|
|
|
|
double Extruder::retraction_length() const
|
|
{
|
|
return m_config->retraction_length.get_at(m_config_index);
|
|
}
|
|
|
|
double Extruder::retract_lift() const
|
|
{
|
|
return m_config->z_hop.get_at(m_config_index);
|
|
}
|
|
|
|
int Extruder::retract_speed() const
|
|
{
|
|
return int(floor(m_config->retraction_speed.get_at(m_config_index)+0.5));
|
|
}
|
|
|
|
bool Extruder::use_firmware_retraction() const
|
|
{
|
|
return m_config->use_firmware_retraction;
|
|
}
|
|
|
|
int Extruder::deretract_speed() const
|
|
{
|
|
int speed = int(floor(m_config->deretraction_speed.get_at(m_config_index)+0.5));
|
|
return (speed > 0) ? speed : this->retract_speed();
|
|
}
|
|
|
|
double Extruder::retract_restart_extra() const
|
|
{
|
|
return m_config->retract_restart_extra.get_at(m_config_index);
|
|
}
|
|
|
|
double Extruder::retract_length_toolchange() const
|
|
{
|
|
return m_config->retract_length_toolchange.get_at(m_config_index);
|
|
}
|
|
|
|
double Extruder::retract_restart_extra_toolchange() const
|
|
{
|
|
return m_config->retract_restart_extra_toolchange.get_at(m_config_index);
|
|
}
|
|
|
|
double Extruder::travel_slope() const
|
|
{
|
|
// Orca: deliberately keyed by the physical extruder, not the filament column — this read
|
|
// predates the per-variant merge and switching it would change existing multi-extruder output.
|
|
return m_config->travel_slope.get_at(extruder_id()) * PI / 180;
|
|
}
|
|
|
|
}
|