Add orca-translations Claude skill and PO tool (#16436)

* 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
This commit is contained in:
Ian Bassi
2026-10-13 10:53:57 -03:00
committed by GitHub
parent b77b5afd49
commit e821665e4b
154 changed files with 98207 additions and 17434 deletions
+46 -40
View File
@@ -809,7 +809,7 @@ void PresetBundle::setup_directories()
BOOST_LOG_TRIVIAL(warning) << boost::format("creating directory %1% failed, maybe created by other instance, go on!")%subdir.string();
}
else
throw Slic3r::RuntimeError(std::string("Unable to create directory ") + subdir.string());
throw Slic3r::RuntimeError((boost::format(L("Unable to create directory %1%")) % subdir.string()).str());
}
}
}
@@ -5451,7 +5451,7 @@ ConfigSubstitutions PresetBundle::load_config_file(const std::string &path, Forw
//BBS: add config related logs
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(" can not load config file %1% not from gcode")%path ;
throw Slic3r::RuntimeError(std::string("Unknown configuration file: ") + path);
throw Slic3r::RuntimeError((boost::format(L("Unknown configuration file: %1%")) % path).str());
return ConfigSubstitutions{};
}
@@ -5653,7 +5653,7 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
ConfigOptionStrings* filament_colour_option = config.option<ConfigOptionStrings>("filament_colour");
size_t num_filaments = filament_colour_option?filament_colour_option->size():0;
if (num_filaments == 0)
throw Slic3r::RuntimeError(std::string("Invalid configuration file: ") + name_or_path);
throw Slic3r::RuntimeError((boost::format(L("Invalid configuration file: %1%")) % name_or_path).str());
#endif
//BBS: add config related logs
@@ -5717,7 +5717,7 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
|| (extruder_variant_count < num_filaments)) {
assert(false);
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(": invalid config file %1%, can not find suitable filament_extruder_variant or filament_self_index") % name_or_path;
throw Slic3r::RuntimeError(std::string("Invalid configuration file: ") + name_or_path);
throw Slic3r::RuntimeError((boost::format(L("Invalid configuration file: %1%")) % name_or_path).str());
}
if (num_filaments != extruder_variant_count) {
process_multi_extruder = true;
@@ -6151,8 +6151,9 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
// A payload mix authored at the same slot (a mix inside the physical region) is
// processed after this sweep and overrides its own destination below.
published_config->mixed_slot_relocations.insert_or_assign(int(slot), int(dest));
published_config->material_replacements.emplace_back("slot " + std::to_string(slot) + " -> slot " +
std::to_string(dest) + ": mixed filament");
// TRN Filament slot change after loading a published project. %1% and %2% are slot numbers.
published_config->material_replacements.emplace_back(
(boost::format(L("slot %1% -> slot %2%: mixed filament")) % slot % dest).str());
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": published 3MF relocated receiver mixed filament slot " << slot
<< " -> " << dest << " (physical-first rebalance)";
}
@@ -6186,9 +6187,10 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
// No free virtual slot left: report instead of destroying a real filament.
// The local skipped_keys is published wholesale at the end of the pass;
// writing published_config->skipped_keys here would be clobbered by it.
skipped_keys.emplace_back("material:" + material_label + (is_payload_mix ?
" (mixed filament definition: filament slot limit reached)" :
" (filament slot limit reached)"));
skipped_keys.emplace_back("material:" + material_label + " (" +
(is_payload_mix ? L("mixed filament definition: filament slot limit reached") :
L("filament slot limit reached")) +
")");
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": published 3MF " << (is_payload_mix ? "mixed filament definition" : "material")
<< " from slot " << entry.slot << " could not be placed: all " << next_free_slot
<< " slots exhausted";
@@ -6200,8 +6202,8 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
// sidebar's mixed section needs two physical filaments to mix), so a
// placeholder would be invisible and unfixable: drop the entry and
// report it like any other unappliable input.
skipped_keys.emplace_back("material:" + material_label + " (printer supports only " +
std::to_string(physical_capacity) + " filament)");
skipped_keys.emplace_back("material:" + material_label + " (" +
(boost::format(L("the printer's filament limit is %1%")) % physical_capacity).str() + ")");
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": published 3MF material from slot " << entry.slot
<< " dropped: printer supports only " << physical_capacity << " filament";
entry_it = published_config->material_keys.erase(entry_it);
@@ -6219,8 +6221,8 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
any_mixed_relocated = true;
mixed_moves.emplace_back(size_t(authored_slot), size_t(entry.slot));
published_config->mixed_slot_relocations.insert_or_assign(authored_slot, entry.slot);
published_config->material_replacements.emplace_back("slot " + std::to_string(authored_slot) + " -> slot " +
std::to_string(entry.slot) + ": mixed filament");
published_config->material_replacements.emplace_back(
(boost::format(L("slot %1% -> slot %2%: mixed filament")) % authored_slot % entry.slot).str());
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": published 3MF relocated mixed filament slot " << authored_slot
<< " -> " << entry.slot;
++entry_it;
@@ -6238,10 +6240,11 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
published_config->mixed_slot_relocations.insert_or_assign(authored_slot, dest_slot);
}
published_config->material_replacements.emplace_back(
(dest_slot != authored_slot ?
"slot " + std::to_string(authored_slot) + " -> slot " + std::to_string(dest_slot) :
"slot " + std::to_string(dest_slot)) +
": unassigned mixed filament (printer supports only " + std::to_string(physical_capacity) + " filaments)");
dest_slot != authored_slot ?
(boost::format(L("slot %1% -> slot %2%: unassigned mixed filament (the printer's filament limit is %3%)")) %
authored_slot % dest_slot % physical_capacity).str() :
(boost::format(L("slot %1%: unassigned mixed filament (the printer's filament limit is %2%)")) % dest_slot %
physical_capacity).str());
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": published 3MF material from slot " << authored_slot
<< " placed as an unassigned mixed filament at slot " << dest_slot
<< " (printer supports only " << physical_capacity << " filaments)";
@@ -6463,8 +6466,9 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
this->filament_presets[slot] = replacement;
material_applied = true;
// The re-point used to be silent; surface it like the other slot changes.
published_config->material_replacements.emplace_back("slot " + std::to_string(slot) + ": " + aliased_name + " -> " +
replacement);
// TRN Filament slot change after loading a published project. %1% is the slot number, %2% the old preset, %3% the new one.
published_config->material_replacements.emplace_back(
(boost::format(L("slot %1%: %2% -> %3%")) % slot % aliased_name % replacement).str());
}
// Grow the per-slot colour/type/map project vectors to the new slot count and
// seed the new entries so the slots render with colours instead of blank chips
@@ -6659,8 +6663,8 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
// definition below.
if (is_mixed_definition(entry) && !this->is_mixed_filament(slot)) {
finalize_mixed_placeholder(slot);
published_config->material_replacements.emplace_back("slot " + std::to_string(slot) +
": mixed filament definition could not be imported");
published_config->material_replacements.emplace_back(
(boost::format(L("slot %1%: mixed filament definition could not be imported")) % slot).str());
}
continue;
}
@@ -6687,17 +6691,18 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
if (comps.size() < 2)
// An empty definition cell counts as broken too: applying it
// would ship a mix the sidebar would only flag later.
mix_error = "needs at least two components";
mix_error = L("needs at least two components");
else
for (unsigned int comp : comps)
if (comp < 1 || size_t(comp) > mixed_final_slot_count ||
mixed_final_slots.count(int(comp) - 1) != 0) {
mix_error = "components reference missing slots";
mix_error = L("components reference missing slots");
break;
}
}
if (!mix_error.empty()) {
skipped_keys.emplace_back("material:" + material_label + " (mixed filament definition: " + mix_error + ")");
skipped_keys.emplace_back("material:" + material_label + " (" +
(boost::format(L("mixed filament definition: %1%")) % mix_error).str() + ")");
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": published 3MF mixed filament from slot " << entry.slot
<< " rejected: " << mix_error;
// Degradation, not silent corruption: the slot was already grown and
@@ -6713,9 +6718,8 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
// is reported as skipped above.
if (!this->is_mixed_filament(slot)) {
finalize_mixed_placeholder(slot);
published_config->material_replacements.emplace_back("slot " + std::to_string(slot) +
": mixed filament definition could not be imported (" +
mix_error + ")");
published_config->material_replacements.emplace_back(
(boost::format(L("slot %1%: mixed filament definition could not be imported (%2%)")) % slot % mix_error).str());
}
continue;
}
@@ -6786,8 +6790,8 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
const std::string old_name = this->filament_presets[slot];
this->filament_presets[slot] = new_name;
material_applied = true;
published_config->material_replacements.emplace_back("slot " + std::to_string(slot) + ": " + old_name + " -> " +
new_name);
published_config->material_replacements.emplace_back(
(boost::format(L("slot %1%: %2% -> %3%")) % slot % old_name % new_name).str());
// Colour is slot-scoped and project-visible: sync into project_config
// (the copy already baked it, this makes the chips render).
if (entry.publish_color && !entry.color.empty()) {
@@ -6906,11 +6910,12 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
<< " (score " << score << ", preset_name \"" << entry.preset_name << "\", filament_id \""
<< entry.filament_id << "\", setting_id \"" << entry.setting_id << "\", type \""
<< entry.publish_type_value << "\")";
std::string replacement_line = "slot " + std::to_string(slot) + ": " + old_name + " -> " + replacement;
// A pick that is not the exact published material is a substitute;
// an entry without identity fields cannot be judged, so it stays plain.
if (score < 2 && (!entry.filament_id.empty() || !entry.filament_vendor.empty()))
replacement_line += " (substitute)";
const bool is_substitute = score < 2 && (!entry.filament_id.empty() || !entry.filament_vendor.empty());
std::string replacement_line = (boost::format(is_substitute ? L("slot %1%: %2% -> %3% (substitute)") :
L("slot %1%: %2% -> %3%")) %
slot % old_name % replacement).str();
published_config->material_replacements.emplace_back(std::move(replacement_line));
} else {
// Partial publish with no replacement: keep the receiver's
@@ -6926,8 +6931,8 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
// mix is left untouched).
if (is_mixed_definition(entry) && !this->is_mixed_filament(slot)) {
finalize_mixed_placeholder(slot);
published_config->material_replacements.emplace_back("slot " + std::to_string(slot) +
": mixed filament definition could not be imported");
published_config->material_replacements.emplace_back(
(boost::format(L("slot %1%: mixed filament definition could not be imported")) % slot).str());
}
}
}
@@ -7010,8 +7015,8 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
if (!this->is_mixed_filament(size_t(gap_slot))) {
finalize_mixed_placeholder(size_t(gap_slot));
published_config->material_replacements.emplace_back(
"slot " + std::to_string(gap_slot) +
": unassigned mixed filament (printer supports only " + std::to_string(physical_capacity) + " filaments)");
(boost::format(L("slot %1%: unassigned mixed filament (the printer's filament limit is %2%)")) % gap_slot %
physical_capacity).str());
}
}
}
@@ -7064,7 +7069,7 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
static ConfigurationError failed_loading_error(const std::string& file, const std::string& dir)
{
return ConfigurationError((boost::format("Failed loading configuration file %1%\nSuggest cleaning the directory %2% firstly") % file % dir).str());
return ConfigurationError((boost::format(L("Failed loading configuration file %1%\nSuggest cleaning the directory %2% first")) % file % dir).str());
}
void PresetBundle::log_errors(const std::vector<std::string>& errors)
@@ -7537,7 +7542,8 @@ void PresetBundle::parse_vendor_json(VendorRead& read)
auto config_version = Semver::parse(version_str);
if (! config_version) {
++m_errors;
throw ConfigurationError((boost::format("vendor %1%'s config version: %2% invalid\nSuggest cleaning the directory %3% firstly")
// TRN %1% is the vendor name, %2% the version found in its profile, %3% the profile directory.
throw ConfigurationError((boost::format(L("Vendor %1%'s config version: %2% invalid\nSuggest cleaning the directory %3% first"))
% vendor_name % version_str % dir).str());
} else {
vendor_profile.config_version = std::move(*config_version);
@@ -7575,7 +7581,7 @@ void PresetBundle::parse_vendor_json(VendorRead& read)
}
catch(nlohmann::detail::parse_error &err) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<<root_file<<" got a nlohmann::detail::parse_error, reason = " << err.what();
throw ConfigurationError((boost::format("Failed loading configuration file %1%: %2%\nSuggest cleaning the directory %3% firstly")
throw ConfigurationError((boost::format(L("Failed loading configuration file %1%: %2%\nSuggest cleaning the directory %3% first"))
%root_file %err.what() % dir).str());
//goto __error_process;
}
@@ -7690,7 +7696,7 @@ void PresetBundle::parse_vendor_json(VendorRead& read)
}
catch(nlohmann::detail::parse_error &err) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<< subfile <<" got a nlohmann::detail::parse_error, reason = " << err.what();
throw ConfigurationError((boost::format("Failed loading configuration file %1%: %2%\nSuggest cleaning the directory %3% firstly")
throw ConfigurationError((boost::format(L("Failed loading configuration file %1%: %2%\nSuggest cleaning the directory %3% first"))
%subfile %err.what() % dir).str());
}