Files
OrcaSlicer/resources/web/flush/WipingDialog.html
T
Ian Bassi e821665e4b 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
2026-10-13 10:53:57 -03:00

672 lines
20 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script type="text/javascript" src="../include/i18n.js"></script>
<style>
* {
user-select: none;
-webkit-user-select: none;
box-sizing: border-box;
}
html, body {
margin: 0px;
padding: 0px;
height: 100%;
background: #f5f5f5;
font-family: sans-serif;
overscroll-behavior: none;
}
body {
position: fixed;
inset: 0;
}
.container {
display: flex;
flex-direction: column;
height: 100%;
background: #fff;
padding: 20px;
padding-bottom: 10px;
border: 1px solid #ccc;
max-width: fit-content(1000px);
margin: 0 auto;
overflow: hidden;
box-sizing: border-box;
}
.tip-panel {
background: #eeeeee;
padding: 10px;
margin-bottom: 10px;
font-size: 12px;
flex-shrink: 0;
}
.scroll-wrapper {
flex: 1 1 0%;
min-height: 0;
display: flex;
flex-direction: column;
}
.scroll-container {
flex: 1 1 0%;
min-height: 80px;
max-width: 100%;
max-height: 500px;
overflow: auto;
border: 1px solid #ccc;
position: relative;
margin: 0px;
}
.description-section {
flex-shrink: 0;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #ccc;
text-align: center;
padding: 2px;
position: relative;
width: 40px;
height: 25px;
}
thead th {
position: sticky;
top: 0;
background: #eee;
z-index: 10;
}
tbody th {
position: sticky;
left: 0;
background: #eee;
z-index: 9;
}
tbody tr:nth-child(even) {
background: #ffffff;
}
tbody tr:nth-child(odd) {
background: #eeeeee;
}
tbody td:first-child,
thead th:first-child {
position: sticky;
top: 0;
left: 0;
background: #eee;
z-index: 11;
}
.icon-button {
display: inline-block;
width: 16px;
height: 16px;
border: 1px solid #999;
text-align: center;
line-height: 15px;
color: #fff;
font-weight: bold;
font-size: 12px;
border-radius: 4px;
cursor: default;
user-select: none;
padding: 1px;
}
input[type="number"].table-input {
width: 30px;
height: 20px;
text-align: center;
-moz-appearance: textfield;
appearance: textfield;
border: none;
background-color: inherit;
}
input[type="number"].table-input::-webkit-inner-spin-button,
input[type="number"].table-input::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
input[type="number"].multiplier-input {
width: 60px;
}
body.dark-mode input[type="number"].multiplier-input {
width: 60px;
background-color: #4c4c55;
color: white;
}
.warning-text {
color: red;
font-size: 12px;
}
.normal-text {
color: black;
font-size: 12px;
}
.icon-gap {
width: 10px;
display: inline-block;
}
.button-container {
display: flex;
justify-content: center;
gap: 0px;
margin-top: 10px;
flex-shrink: 0;
}
/* 暗色模式样式 */
body.dark-mode {
background-color: #2d2d31;
color: #e0e0e0;
}
body.dark-mode .container {
background: inherit;
border-color: #2d2d31;
}
body.dark-mode .tip-panel {
background: #4c4c55;
color: #ccc;
}
body.dark-mode .scroll-container {
border-color: #4c4c55;
}
body.dark-mode table {
background: inherit;
border-color: #4c4c55;
}
body.dark-mode input[type="number"].table-input {
width: 30px;
height: 20px;
text-align: center;
-moz-appearance: textfield;
appearance: textfield;
border: none;
color: #e0e0e0;
background-color: inherit;
}
body.dark-mode th, body.dark-mode td {
background: inherit;
border-color: #555;
color: #e0e0e0;
}
body.dark-mode thead th{
position: sticky;
z-index: 10
}
body.dark-mode tbody th{
position: sticky;
z-index: 9
}
body.dark-mode tbody tr:nth-child(even) {
background: #2d2d31;
}
body.dark-mode tbody tr:nth-child(odd) {
background: #4c4c55;
}
body.dark-mode tbody td:first-child,
body.dark-mode thead th:first-child {
position: sticky;
z-index: 11;
}
body.dark-mode .warning-text {
color: #f44336;
}
body.dark-mode .normal-text {
color: #e0e0e0;
}
body.dark-mode .icon-button {
background-color: #4c4c55;
}
</style>
</head>
<link rel="stylesheet" type="text/css" href="../include/global.css" /> <!-- ORCA One for all-->
<body>
<div class="container">
<div class="tip-panel" id="auto_flush_tip">
Orca would re-calculate your flushing volumes every time the filament
color changed or filaments changed. You could disable the auto-calculate
in Orca Slicer &gt; Preferences.
</div>
<div style="margin-bottom: 10px; display: flex; align-items: center; flex-shrink: 0;">
<div
class="ButtonStyleConfirm ButtonTypeWindow"
onclick="calcFlushingVolumes()"
id="calc_btn"
>
Re-Calculate
</div>
<div class="ComboBox">
<div class="arrow-icon"></div>
<select
id="extruders"
onchange="handleExtruderSelect(document.getElementById('extruders').value)"
>
<option value="left" id="extruder_label_0">Left Nozzle</option>
<option value="right" id="extruder_label_1">Right Nozzle</option>
</select>
</div>
</div>
<div class="scroll-wrapper">
<div class="scroll-container">
<table id="flushTable">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="description-section" style="margin-top: 10px;">
<div id="volume_desp_panel" class="normal-text">
Flushing volume (mm³) for each filament pair.
</div>
<div
id="volume_range_panel"
class="normal-text"
style="margin-top: 5px;"
>
Suggestion: Flushing Volume in range [50, 999]
</div>
<div style="margin-top: 8px;">
<label
for="multiplierInput"
id="multiplier_label"
style="font-size: 12px;"
>Multiplier</label
>
<input
type="number"
step="0.1"
id="multiplierInput"
class="multiplier-input"
value="1.00"
oninput="onMultiplierChange()"
/>
</div>
<div
style="margin-top: 5px; margin-bottom: 5px; color: #666; font-size: 12px;"
id="multiplier_range_panel"
>
The multiplier should be in range [0.50, 3.00].
</div>
</div>
</div>
<div class="button-container" style="padding: 0px; margin: 0px;">
<div class="ButtonStyleConfirm ButtonTypeChoice" id="ok_btn" onclick="storeData()">
Save
</div>
<div class="ButtonStyleRegular ButtonTypeChoice" id="cancel_btn" onclick="quit()">
Cancel
</div>
</div>
</div>
<script>
let m_number_of_filaments // 材料数量
let m_number_of_extruders // 喷嘴数量
let m_colours // 颜色
let m_display_matrix // 显示的矩阵
let m_raw_matrix // 原始数据
let m_flush_multipiers // 冲刷系数
let m_cell_inputs = []; //显示的内容
let m_curr_extruder_id = 0
let m_min_flush_volumes = []
let m_max_flush_volumes = []
let m_min_flush_multiplier = 0.50
let m_max_flush_multiplier = 3
let m_default_matrix //系统默认矩阵
function storeData() {
var data = JSON.stringify({
msg: 'storeData',
number_of_extruders: m_number_of_extruders,
raw_matrix: m_raw_matrix,
flush_multiplier: m_flush_multipiers
})
window.wipingDialog.postMessage(data);
}
function quit() {
var data = JSON.stringify({
msg: 'quit'
})
window.wipingDialog.postMessage(data);
}
function calcFlushingVolumes() {
var data = JSON.stringify({
msg: 'updateMatrix',
extruder_id: m_curr_extruder_id
})
window.wipingDialog.postMessage(data);
}
function updateTable(dataMatrix, extruder_id) {
for (let i = 0; i < m_number_of_filaments; i++) {
for (let j = 0; j < m_number_of_filaments; j++) {
var newValue
var index = m_number_of_filaments * i + j
newValue = (i == j ? 0 : rawToDislay(dataMatrix[index] ,m_flush_multipiers[extruder_id]))
newValue = limitDisplayVal(newValue,extruder_id)
m_cell_inputs[i][j].value = newValue;
m_display_matrix[index] = newValue;
m_raw_matrix[extruder_id][index] = dataMatrix[index]
}
}
updateWarningTexts();
}
// const virtual_data = {
// filament_colors: [
// '#123456', '#7890AB', '#CDEF01', '#F1A2B3', '#4D8B72', '#D9E1F2', '#B76C8C', '#A9C3D3',
// '#FF5733', '#33FF57', '#5733FF', '#FF33FF', '#FFFF33', '#33FFFF', '#FF5733', '#3333FF'
// ],
// extruder_num: 2,
// flush_volume_matrixs: [
// Array.from({ length: 256 }, () => Math.floor(Math.random() * 1000)),
// Array.from({ length: 256 }, () => Math.floor(Math.random() * 1000))
// ],
// flush_multiplier:[1,1]
// }
window.addEventListener("DOMContentLoaded",function(){
var data = JSON.stringify({
msg: 'init',
})
window.wipingDialog.postMessage(data);
});
// Escape should close the dialog even when focus is inside web content.
document.addEventListener("keydown", function (event) {
if (event.key === "Escape") {
event.preventDefault();
event.stopPropagation();
quit();
}
}, true);
function buildText(data) {
document.getElementById('volume_desp_panel').innerText = data.volume_desp_panel
document.getElementById('volume_range_panel').innerText = data.volume_range_panel
document.getElementById('multiplier_range_panel').innerText = data.multiplier_range_panel
document.getElementById('auto_flush_tip').innerText = data.auto_flush_tip
document.getElementById('calc_btn').innerText = data.calc_btn_panel
document.getElementById('extruder_label_0').innerText = data.extruder_label_0
document.getElementById('extruder_label_1').innerText = data.extruder_label_1
document.getElementById('multiplier_label').innerText = data.multiplier_label
document.getElementById('ok_btn').innerText = data.ok_btn_label
document.getElementById('cancel_btn').innerText = data.cancel_btn_label
updateVolumeRange(m_min_flush_volumes[m_curr_extruder_id],m_max_flush_volumes[m_curr_extruder_id])
updateMultiplierRange(m_min_flush_multiplier,m_max_flush_multiplier)
}
// 计算亮度
function getLuminance(color) {
const hex = color.replace(/^#/, '');
const r = parseInt(hex.slice(0, 2), 16);
const g = parseInt(hex.slice(2, 4), 16);
const b = parseInt(hex.slice(4, 6), 16);
return (0.299 * r + 0.587 * g + 0.114 * b) / 255;
}
function updateVolumeRange(min_volume,max_volume){
// Orca: "Typical" guidance only unlinked from upper bound in the slicer.
const TYPICAL_MAX_FLUSH_VOLUME = 900;
const panel = document.getElementById('volume_range_panel');
panel.innerText = panel.innerText.replace(/\[.*\]/, `[${min_volume}, ${TYPICAL_MAX_FLUSH_VOLUME}]`);
}
function updateMultiplierRange(min_multiplier,max_multiplier){
const panel = document.getElementById('multiplier_range_panel');
panel.innerText = panel.innerText.replace(/\[.*\]/, `[${min_multiplier}, ${max_multiplier}]`);
}
function updateFlushMultiplier(extruder_id){
document.getElementById("multiplierInput").value = m_flush_multipiers[extruder_id]
}
function rawToDislay(val, ratio){
return Math.round(val * ratio)
}
function displayToRaw(val, ratio){
if(ratio==0)
return 0
else
return Math.round(val / ratio)
}
function limitDisplayVal(val,extruder_id){
if (isNaN(val))
return 0
if (val < 0)
return 0
if (val > m_max_flush_volumes[extruder_id])
return m_max_flush_volumes[extruder_id];
return val
}
function buildTable(data) {
m_colours = data.filament_colors
m_number_of_extruders = data.extruder_num
m_number_of_filaments = data.filament_colors.length
m_display_matrix = data.flush_volume_matrixs[0].slice();
m_raw_matrix = data.flush_volume_matrixs.map(function(arr) {
return arr.slice();
});
m_default_matrix = data.default_matrixs.map(function (arr) {
return arr.slice();
});
m_flush_multipiers = data.flush_multiplier.slice()
m_max_flush_volumes = data.max_flush_volumes
m_min_flush_volumes = data.min_flush_volumes
m_min_flush_multiplier = data.min_flush_multiplier
m_max_flush_multiplier = data.max_flush_multiplier
if(data.is_dark_mode == true)
document.body.classList.add('dark-mode');
updateFlushMultiplier(m_curr_extruder_id)
const selectElement = document.getElementById('extruders');
if (m_number_of_extruders > 1) {
selectElement.style.display = 'inline-block';
} else {
selectElement.style.display = 'none';
}
var thead = document.querySelector("#flushTable thead tr");
var tbody = document.querySelector("#flushTable tbody");
thead.innerHTML = "";
tbody.innerHTML = "";
for (let j = 0; j < m_number_of_filaments; j++) {
if (j == 0) {
var tag = document.createElement("th")
tag.innerHTML = "<div style='font-size:12px'>" + T("from_to", "from/to") + "</div>"
thead.appendChild(tag)
}
let th = document.createElement("th");
const luminance = getLuminance(m_colours[j]);
const textColor = luminance > 0.5 ? "black" : "white";
th.innerHTML = `<div class="icon-button" style="font-size:10px;background:${m_colours[j]}; color:${textColor};">${j + 1}</div>`;
thead.appendChild(th);
}
for (let i = 0; i < m_number_of_filaments; i++) {
let tr = document.createElement("tr");
let rowHeader = document.createElement("th");
const luminance = getLuminance(m_colours[i]);
const textColor = luminance > 0.5 ? "black" : "white";
rowHeader.innerHTML = `<div class="icon-button" style="font-size:10px; background:${m_colours[i]};color:${textColor};">${i + 1}</div>`;
tr.appendChild(rowHeader);
m_cell_inputs[i] = [];
for (let j = 0; j < m_number_of_filaments; j++) {
let td = document.createElement("td");
td.style.overflow = "hidden";
td.style.textOverflow = "ellipsis";
let displayVal = rawToDislay(m_raw_matrix[m_curr_extruder_id][m_number_of_filaments * i + j], m_flush_multipiers[m_curr_extruder_id])
displayVal = limitDisplayVal(displayVal, m_curr_extruder_id)
m_display_matrix[m_number_of_filaments*i + j] = displayVal
let readonly = (i === j);
let input = document.createElement("input");
input.className = "table-input"
input.type = "number";
input.value = readonly ? 0 : displayVal;
if (readonly) {
input.readOnly = true;
}
input.addEventListener("input", (e) => onCellInput(i, j, e));
m_cell_inputs[i][j] = input;
td.appendChild(input);
tr.appendChild(td);
}
tbody.appendChild(tr);
}
updateWarningTexts();
}
function onCellInput(i, j, event) {
const input = event.target;
let val = parseInt(input.value, 10);
val = limitDisplayVal(val, m_curr_extruder_id);
input.value = val;
if (i !== j) {
var index = m_number_of_filaments*i+j
m_raw_matrix[m_curr_extruder_id][index] = displayToRaw(val, m_flush_multipiers[m_curr_extruder_id])
m_display_matrix[index] = val;
}
updateWarningTexts();
}
function handleExtruderSelect(extruder) {
m_curr_extruder_id = extruder == 'left' ? 0 : 1
updateVolumeRange(m_min_flush_volumes[m_curr_extruder_id],m_max_flush_volumes[m_curr_extruder_id])
updateFlushMultiplier(m_min_flush_multiplier[m_curr_extruder_id],m_max_flush_multiplier[m_curr_extruder_id])
updateFlushMultiplier(m_curr_extruder_id)
updateTable(m_raw_matrix[m_curr_extruder_id], m_curr_extruder_id)
}
function onMultiplierChange() {
let val = parseFloat(document.getElementById("multiplierInput").value);
if (isNaN(val)) val = 1.0;
if(val<m_min_flush_multiplier){
val = m_min_flush_multiplier
document.getElementById("multiplierInput").value = m_min_flush_multiplier;
}
else if(val>m_max_flush_multiplier){
val = m_max_flush_multiplier
document.getElementById("multiplierInput").value = m_max_flush_multiplier;
}
m_flush_multipiers[m_curr_extruder_id] = val;
for (let i = 0; i < m_number_of_filaments; i++) {
for (let j = 0; j < m_number_of_filaments; j++) {
if (i === j) continue;
var index = i * m_number_of_filaments + j;
let displayVal = rawToDislay(m_raw_matrix[m_curr_extruder_id][index] ,m_flush_multipiers[m_curr_extruder_id])
displayVal = limitDisplayVal(displayVal, m_curr_extruder_id)
m_cell_inputs[i][j].value = displayVal;
m_display_matrix[index] = displayVal;
}
}
updateWarningTexts();
}
function updateWarningTexts() {
let val = parseFloat(document.getElementById("multiplierInput").value);
const input = document.getElementById('multiplierInput');
if (val !== 1.0) {
input.style.color = 'orange';
} else {
input.style.color = 'black';
}
let hasException = false;
for (let i = 0; i < m_number_of_filaments; i++) {
for (let j = 0; j < m_number_of_filaments; j++) {
if (i === j) continue;
const input = m_cell_inputs[i][j];
let val = parseInt(input.value, 10);
if (isNaN(val)) val = 0;
var index = i * m_number_of_filaments + j;
let defaultVal = rawToDislay(m_default_matrix[m_curr_extruder_id][index], m_flush_multipiers[m_curr_extruder_id])
if (val < m_min_flush_volumes[m_curr_extruder_id] || val > m_max_flush_volumes[m_curr_extruder_id]) {
input.style.color = "red";
hasException = true;
}
else if (val != defaultVal) {
input.style.color = "orange";
}
else {
input.style.removeProperty("color");
}
}
}
const rangeLabel = document.getElementById("volume_range_panel");
if (hasException) {
rangeLabel.classList.remove("normal-text");
rangeLabel.classList.add("warning-text");
} else {
rangeLabel.classList.remove("warning-text");
rangeLabel.classList.add("normal-text");
}
}
</script>
</body>
</html>