feat(locale): localize full interface

This commit is contained in:
Hakan Seven 2026-08-02 22:09:25 +03:00
commit 3e6693b93f
205 changed files with 32367 additions and 3808 deletions

View file

@ -36,15 +36,15 @@ impl OpenCADStudio {
})
.collect();
self.command_line
.push_output(&format!("Layers: {}", info.join(", ")));
.push_output(crate::tf!("Layers: {}", info.join(", ")).as_ref());
}
"NEW" | "N" => {
let name = parts.get(1).map(|s| s.trim()).unwrap_or("").to_string();
if name.is_empty() {
self.command_line.push_error("Usage: LAYER NEW <name>");
self.command_line.push_error(crate::t!("Usage: LAYER NEW <name>").as_ref());
} else if self.tabs[i].scene.document.layers.contains(&name) {
self.command_line
.push_error(&format!("LAYER: '{}' already exists.", name));
.push_error(crate::tf!("LAYER: '{}' already exists.", name).as_ref());
} else {
let mut layer = Layer::new(&name);
// Allocate a unique handle so the layer survives a
@ -54,7 +54,7 @@ impl OpenCADStudio {
self.push_undo_snapshot(i, "LAYER NEW");
self.tabs[i].dirty = true;
self.command_line
.push_output(&format!("LAYER: '{}' created.", name));
.push_output(crate::tf!("LAYER: '{}' created.", name).as_ref());
}
}
"ON" => {
@ -66,7 +66,7 @@ impl OpenCADStudio {
}
self.push_undo_snapshot(i, "LAYER ON");
self.tabs[i].dirty = true;
self.command_line.push_output("LAYER: layers turned on.");
self.command_line.push_output(crate::t!("LAYER: layers turned on.").as_ref());
}
"OFF" => {
for name in &parts[1..] {
@ -76,7 +76,7 @@ impl OpenCADStudio {
}
self.push_undo_snapshot(i, "LAYER OFF");
self.tabs[i].dirty = true;
self.command_line.push_output("LAYER: layers turned off.");
self.command_line.push_output(crate::t!("LAYER: layers turned off.").as_ref());
}
"FREEZE" | "FR" => {
for name in &parts[1..] {
@ -86,7 +86,7 @@ impl OpenCADStudio {
}
self.push_undo_snapshot(i, "LAYER FREEZE");
self.tabs[i].dirty = true;
self.command_line.push_output("LAYER: layers frozen.");
self.command_line.push_output(crate::t!("LAYER: layers frozen.").as_ref());
}
"THAW" | "TH" => {
for name in &parts[1..] {
@ -96,7 +96,7 @@ impl OpenCADStudio {
}
self.push_undo_snapshot(i, "LAYER THAW");
self.tabs[i].dirty = true;
self.command_line.push_output("LAYER: layers thawed.");
self.command_line.push_output(crate::t!("LAYER: layers thawed.").as_ref());
}
"LOCK" | "LO" => {
for name in &parts[1..] {
@ -106,7 +106,7 @@ impl OpenCADStudio {
}
self.push_undo_snapshot(i, "LAYER LOCK");
self.tabs[i].dirty = true;
self.command_line.push_output("LAYER: layers locked.");
self.command_line.push_output(crate::t!("LAYER: layers locked.").as_ref());
}
"UNLOCK" | "UL" => {
for name in &parts[1..] {
@ -116,7 +116,7 @@ impl OpenCADStudio {
}
self.push_undo_snapshot(i, "LAYER UNLOCK");
self.tabs[i].dirty = true;
self.command_line.push_output("LAYER: layers unlocked.");
self.command_line.push_output(crate::t!("LAYER: layers unlocked.").as_ref());
}
"COLOR" | "C" => {
// LAYER COLOR <name> <aci_index>
@ -137,17 +137,17 @@ impl OpenCADStudio {
.invalidate_layer_dependencies(std::slice::from_ref(
&layer_name,
));
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"LAYER: '{}' color set to ACI {}.",
layer_name, idx
));
).as_ref());
} else {
self.command_line
.push_error(&format!("LAYER: '{}' not found.", layer_name));
.push_error(crate::tf!("LAYER: '{}' not found.", layer_name).as_ref());
}
} else {
self.command_line
.push_error("Usage: LAYER COLOR <name> <aci_index>");
.push_error(crate::t!("Usage: LAYER COLOR <name> <aci_index>").as_ref());
}
}
"SET" | "S" | "CURRENT" => {
@ -155,15 +155,15 @@ impl OpenCADStudio {
if self.tabs[i].scene.document.layers.contains(&name) {
self.tabs[i].layers.current_layer = name.clone();
self.command_line
.push_output(&format!("LAYER: current layer set to '{}'.", name));
.push_output(crate::tf!("LAYER: current layer set to '{}'.", name).as_ref());
} else {
self.command_line
.push_error(&format!("LAYER: '{}' not found.", name));
.push_error(crate::tf!("LAYER: '{}' not found.", name).as_ref());
}
}
_ => {
self.command_line.push_info(
"Usage: LAYER LIST | NEW <name> | ON/OFF/FREEZE/THAW/LOCK/UNLOCK <name> | COLOR <name> <aci> | SET <name>"
crate::t!("Usage: LAYER LIST | NEW <name> | ON/OFF/FREEZE/THAW/LOCK/UNLOCK <name> | COLOR <name> <aci> | SET <name>").as_ref()
);
}
}
@ -202,22 +202,22 @@ impl OpenCADStudio {
.map(|u| u.name.clone())
.collect();
if names.is_empty() {
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"Active UCS: {} | No named UCSs defined.",
active_name
));
).as_ref());
} else {
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"Active UCS: {} | Named: {}",
active_name,
names.join(", ")
));
).as_ref());
}
}
"SAVE" | "S" => {
let name = parts.get(2).map(|s| s.trim()).unwrap_or("").to_string();
if name.is_empty() {
self.command_line.push_error("Usage: UCS SAVE <name>");
self.command_line.push_error(crate::t!("Usage: UCS SAVE <name>").as_ref());
} else {
// Save the current active UCS under this name.
let ucs = match &self.tabs[i].active_ucs {
@ -231,27 +231,27 @@ impl OpenCADStudio {
self.tabs[i].scene.document.ucss.add_or_replace(ucs);
self.tabs[i].dirty = true;
self.command_line
.push_output(&format!("UCS '{}' saved.", name));
.push_output(crate::tf!("UCS '{}' saved.", name).as_ref());
}
}
"DELETE" | "DEL" | "D" => {
let name = parts.get(2).map(|s| s.trim()).unwrap_or("").to_string();
if name.is_empty() {
self.command_line.push_error("Usage: UCS DELETE <name>");
self.command_line.push_error(crate::t!("Usage: UCS DELETE <name>").as_ref());
} else if self.tabs[i].scene.document.ucss.remove(&name).is_some() {
self.tabs[i].dirty = true;
self.command_line
.push_output(&format!("UCS '{}' deleted.", name));
.push_output(crate::tf!("UCS '{}' deleted.", name).as_ref());
} else {
self.command_line
.push_error(&format!("UCS '{}' not found.", name));
.push_error(crate::tf!("UCS '{}' not found.", name).as_ref());
}
}
"W" | "WORLD" => {
self.tabs[i].active_ucs = None;
active_changed = true;
self.command_line
.push_output("UCS reset to World Coordinate System.");
.push_output(crate::t!("UCS reset to World Coordinate System.").as_ref());
}
// UCS ORIGIN x,y,z — shift the active UCS origin, keep axes
"ORIGIN" | "O" => {
@ -274,12 +274,12 @@ impl OpenCADStudio {
wcs_origin.z as f64,
);
active_changed = true;
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"UCS origin set to ({:.4}, {:.4}, {:.4}).",
wcs_origin.x, wcs_origin.y, wcs_origin.z
));
).as_ref());
} else {
self.command_line.push_error("Usage: UCS ORIGIN x,y,z");
self.command_line.push_error(crate::t!("Usage: UCS ORIGIN x,y,z").as_ref());
}
}
// UCS Z angle — rotate active UCS around its Z axis by degrees
@ -318,9 +318,9 @@ impl OpenCADStudio {
self.tabs[i].active_ucs = Some(new_ucs);
active_changed = true;
self.command_line
.push_output(&format!("UCS rotated {:.2}° around Z.", angle_deg));
.push_output(crate::tf!("UCS rotated {:.2}° around Z.", angle_deg).as_ref());
} else {
self.command_line.push_error("Usage: UCS Z <angle_degrees>");
self.command_line.push_error(crate::t!("Usage: UCS Z <angle_degrees>").as_ref());
}
}
// UCS X angle — rotate around current UCS X axis
@ -346,9 +346,9 @@ impl OpenCADStudio {
ucs.y_axis = Vector3::new(ny.x as f64, ny.y as f64, ny.z as f64);
active_changed = true;
self.command_line
.push_output(&format!("UCS rotated {:.2}° around X.", angle_deg));
.push_output(crate::tf!("UCS rotated {:.2}° around X.", angle_deg).as_ref());
} else {
self.command_line.push_error("Usage: UCS X <angle_degrees>");
self.command_line.push_error(crate::t!("Usage: UCS X <angle_degrees>").as_ref());
}
}
// UCS Y angle — rotate around current UCS Y axis
@ -374,9 +374,9 @@ impl OpenCADStudio {
ucs.x_axis = Vector3::new(nx.x as f64, nx.y as f64, nx.z as f64);
active_changed = true;
self.command_line
.push_output(&format!("UCS rotated {:.2}° around Y.", angle_deg));
.push_output(crate::tf!("UCS rotated {:.2}° around Y.", angle_deg).as_ref());
} else {
self.command_line.push_error("Usage: UCS Y <angle_degrees>");
self.command_line.push_error(crate::t!("Usage: UCS Y <angle_degrees>").as_ref());
}
}
_ => {
@ -386,12 +386,12 @@ impl OpenCADStudio {
self.tabs[i].active_ucs = Some(named);
active_changed = true;
self.command_line
.push_output(&format!("UCS '{}' activated.", name));
.push_output(crate::tf!("UCS '{}' activated.", name).as_ref());
} else {
self.command_line.push_error(&format!(
self.command_line.push_error(crate::tf!(
"UCS '{}' not found. Usage: UCS LIST | SAVE <name> | DELETE <name> | W | ORIGIN x,y,z | X/Y/Z <angle>",
name
));
).as_ref());
}
}
}
@ -429,16 +429,16 @@ impl OpenCADStudio {
"" | "CURRENT" | "C" => {
let r = self.tabs[i].scene.viewcube_ucs_mat();
self.plan_snap(i, r);
self.command_line.push_output("PLAN: current UCS plan view.");
self.command_line.push_output(crate::t!("PLAN: current UCS plan view.").as_ref());
}
"WORLD" | "W" => {
self.plan_snap(i, glam::Mat4::IDENTITY);
self.command_line.push_output("PLAN: world plan view.");
self.command_line.push_output(crate::t!("PLAN: world plan view.").as_ref());
}
"UCS" | "U" => {
let name = parts.get(2).map(|s| s.trim()).unwrap_or("");
if name.is_empty() {
self.command_line.push_info("Usage: PLAN UCS <name>");
self.command_line.push_info(crate::t!("Usage: PLAN UCS <name>").as_ref());
} else {
let ucs = self.tabs[i]
.scene
@ -452,20 +452,20 @@ impl OpenCADStudio {
let r = crate::app::helpers::UcsXform::from_ucs(&u)
.rotation_mat();
self.plan_snap(i, r);
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"PLAN: plan view of UCS '{}'.",
u.name
));
).as_ref());
}
None => self
.command_line
.push_error(&format!("UCS '{name}' not found.")),
.push_error(crate::tf!("UCS '{name}' not found.").as_ref()),
}
}
}
_ => self
.command_line
.push_info("Usage: PLAN [CURRENT / UCS <name> / WORLD]"),
.push_info(crate::t!("Usage: PLAN [CURRENT / UCS <name> / WORLD]").as_ref()),
}
}
@ -497,50 +497,50 @@ impl OpenCADStudio {
.map(|v| v.name.clone())
.collect();
if views.is_empty() {
self.command_line.push_output("No named views saved.");
self.command_line.push_output(crate::t!("No named views saved.").as_ref());
} else {
self.command_line
.push_output(&format!("Named views: {}", views.join(", ")));
.push_output(crate::tf!("Named views: {}", views.join(", ")).as_ref());
}
}
"SAVE" | "S" => {
let name = parts.get(2).map(|s| s.trim()).unwrap_or("").to_string();
if name.is_empty() {
self.command_line.push_error("Usage: VIEW SAVE <name>");
self.command_line.push_error(crate::t!("Usage: VIEW SAVE <name>").as_ref());
} else {
let new_view = self.tabs[i].scene.current_as_named_view(&name);
self.tabs[i].scene.document.views.add_or_replace(new_view);
self.command_line
.push_output(&format!("View '{}' saved.", name));
.push_output(crate::tf!("View '{}' saved.", name).as_ref());
}
}
"DELETE" | "DEL" | "D" => {
let name = parts.get(2).map(|s| s.trim()).unwrap_or("").to_string();
if name.is_empty() {
self.command_line.push_error("Usage: VIEW DELETE <name>");
self.command_line.push_error(crate::t!("Usage: VIEW DELETE <name>").as_ref());
} else {
if self.tabs[i].scene.document.views.remove(&name).is_some() {
self.command_line
.push_output(&format!("View '{}' deleted.", name));
.push_output(crate::tf!("View '{}' deleted.", name).as_ref());
} else {
self.command_line
.push_error(&format!("View '{}' not found.", name));
.push_error(crate::tf!("View '{}' not found.", name).as_ref());
}
}
}
"RESTORE" | "R" => {
let name = parts.get(2).map(|s| s.trim()).unwrap_or("").to_string();
if name.is_empty() {
self.command_line.push_error("Usage: VIEW RESTORE <name>");
self.command_line.push_error(crate::t!("Usage: VIEW RESTORE <name>").as_ref());
} else {
let found = self.tabs[i].scene.document.views.get(&name).cloned();
if let Some(v) = found {
self.tabs[i].scene.restore_named_view(&v);
self.command_line
.push_output(&format!("View '{}' restored.", v.name));
.push_output(crate::tf!("View '{}' restored.", v.name).as_ref());
} else {
self.command_line
.push_error(&format!("View '{}' not found.", name));
.push_error(crate::tf!("View '{}' not found.", name).as_ref());
}
}
}
@ -573,10 +573,10 @@ impl OpenCADStudio {
if let Some(v) = found {
self.tabs[i].scene.restore_named_view(&v);
self.command_line
.push_output(&format!("View '{}' restored.", v.name));
.push_output(crate::tf!("View '{}' restored.", v.name).as_ref());
} else {
self.command_line.push_error(
"Usage: VIEW LIST | VIEW SAVE <name> | VIEW RESTORE <name> | VIEW DELETE <name>"
crate::t!("Usage: VIEW LIST | VIEW SAVE <name> | VIEW RESTORE <name> | VIEW DELETE <name>").as_ref()
);
}
}
@ -614,16 +614,16 @@ impl OpenCADStudio {
})
.collect();
if styles.is_empty() {
self.command_line.push_output("No table styles.");
self.command_line.push_output(crate::t!("No table styles.").as_ref());
} else {
self.command_line
.push_output(&format!("TableStyles:\n {}", styles.join("\n ")));
.push_output(crate::tf!("TableStyles:\n {}", styles.join("\n ")).as_ref());
}
}
"NEW" | "N" => {
let name = parts.get(1).copied().unwrap_or("").to_string();
if name.is_empty() {
self.command_line.push_error("Usage: TABLESTYLE NEW <name>");
self.command_line.push_error(crate::t!("Usage: TABLESTYLE NEW <name>").as_ref());
} else {
let doc = &self.tabs[i].scene.document;
let exists = doc.objects.values().any(|o| {
@ -631,7 +631,7 @@ impl OpenCADStudio {
});
if exists {
self.command_line
.push_error(&format!("TABLESTYLE: '{}' already exists.", name));
.push_error(crate::tf!("TABLESTYLE: '{}' already exists.", name).as_ref());
} else {
self.push_undo_snapshot(i, "TABLESTYLE NEW");
let mut style = TableStyle::standard();
@ -647,13 +647,13 @@ impl OpenCADStudio {
.insert(nh, ObjectType::TableStyle(style));
self.tabs[i].dirty = true;
self.command_line
.push_output(&format!("TABLESTYLE: '{}' created.", name));
.push_output(crate::tf!("TABLESTYLE: '{}' created.", name).as_ref());
}
}
}
_ => {
self.command_line
.push_error("Usage: TABLESTYLE [LIST|NEW <name>]");
.push_error(crate::t!("Usage: TABLESTYLE [LIST|NEW <name>]").as_ref());
}
}
}
@ -693,16 +693,16 @@ impl OpenCADStudio {
})
.collect();
if styles.is_empty() {
self.command_line.push_output("No multiline styles.");
self.command_line.push_output(crate::t!("No multiline styles.").as_ref());
} else {
self.command_line
.push_output(&format!("MLineStyles:\n {}", styles.join("\n ")));
.push_output(crate::tf!("MLineStyles:\n {}", styles.join("\n ")).as_ref());
}
}
"NEW" | "N" => {
let name = parts.get(1).copied().unwrap_or("").to_string();
if name.is_empty() {
self.command_line.push_error("Usage: MLSTYLE NEW <name>");
self.command_line.push_error(crate::t!("Usage: MLSTYLE NEW <name>").as_ref());
} else {
let doc = &self.tabs[i].scene.document;
let exists = doc.objects.values().any(|o| {
@ -710,7 +710,7 @@ impl OpenCADStudio {
});
if exists {
self.command_line
.push_error(&format!("MLSTYLE: '{}' already exists.", name));
.push_error(crate::tf!("MLSTYLE: '{}' already exists.", name).as_ref());
} else {
self.push_undo_snapshot(i, "MLSTYLE NEW");
let mut style = MLineStyle::standard();
@ -726,14 +726,14 @@ impl OpenCADStudio {
.insert(nh, ObjectType::MLineStyle(style));
self.tabs[i].dirty = true;
self.command_line
.push_output(&format!("MLSTYLE: '{}' created.", name));
.push_output(crate::tf!("MLSTYLE: '{}' created.", name).as_ref());
}
}
}
"SET" | "S" => {
let name = parts.get(1).copied().unwrap_or("").to_string();
if name.is_empty() {
self.command_line.push_error("Usage: MLSTYLE SET <name>");
self.command_line.push_error(crate::t!("Usage: MLSTYLE SET <name>").as_ref());
} else {
let doc = &self.tabs[i].scene.document;
let exists = doc.objects.values().any(|o| {
@ -743,13 +743,13 @@ impl OpenCADStudio {
self.push_undo_snapshot(i, "MLSTYLE SET");
self.tabs[i].scene.document.header.multiline_style = name.clone();
self.tabs[i].dirty = true;
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"MLSTYLE: current style set to '{}'.",
name
));
).as_ref());
} else {
self.command_line
.push_error(&format!("MLSTYLE: '{}' not found.", name));
.push_error(crate::tf!("MLSTYLE: '{}' not found.", name).as_ref());
}
}
}
@ -757,7 +757,7 @@ impl OpenCADStudio {
let name = parts.get(1).copied().unwrap_or("").to_string();
if name.is_empty() || name.eq_ignore_ascii_case("Standard") {
self.command_line
.push_error("Cannot delete the Standard style.");
.push_error(crate::t!("Cannot delete the Standard style.").as_ref());
} else {
let doc = &self.tabs[i].scene.document;
let handle = doc.objects.iter().find_map(|(&h, o)| {
@ -776,16 +776,16 @@ impl OpenCADStudio {
self.tabs[i].scene.document.objects.remove(&h);
self.tabs[i].dirty = true;
self.command_line
.push_output(&format!("MLSTYLE: '{}' deleted.", name));
.push_output(crate::tf!("MLSTYLE: '{}' deleted.", name).as_ref());
} else {
self.command_line
.push_error(&format!("MLSTYLE: '{}' not found.", name));
.push_error(crate::tf!("MLSTYLE: '{}' not found.", name).as_ref());
}
}
}
_ => {
self.command_line
.push_error("Usage: MLSTYLE [LIST|NEW <name>|SET <name>|DEL <name>]");
.push_error(crate::t!("Usage: MLSTYLE [LIST|NEW <name>|SET <name>|DEL <name>]").as_ref());
}
}
}
@ -813,19 +813,19 @@ impl OpenCADStudio {
.map(|s| format!("{}(txt:{:.2} asz:{:.2})", s.name, s.dimtxt, s.dimasz))
.collect();
if styles.is_empty() {
self.command_line.push_output("No dim styles defined.");
self.command_line.push_output(crate::t!("No dim styles defined.").as_ref());
} else {
self.command_line
.push_output(&format!("DimStyles: {}", styles.join(", ")));
.push_output(crate::tf!("DimStyles: {}", styles.join(", ")).as_ref());
}
}
"NEW" | "N" => {
let name = parts.get(1).map(|s| s.trim()).unwrap_or("").to_string();
if name.is_empty() {
self.command_line.push_error("Usage: DIMSTYLE NEW <name>");
self.command_line.push_error(crate::t!("Usage: DIMSTYLE NEW <name>").as_ref());
} else if self.tabs[i].scene.document.dim_styles.contains(&name) {
self.command_line
.push_error(&format!("DIMSTYLE: '{}' already exists.", name));
.push_error(crate::tf!("DIMSTYLE: '{}' already exists.", name).as_ref());
} else {
let undo = self.begin_dim_style_undo(
i,
@ -837,7 +837,7 @@ impl OpenCADStudio {
self.tabs[i].dirty = true;
self.commit_dim_style_undo(i, undo);
self.command_line
.push_output(&format!("DIMSTYLE: '{}' created.", name));
.push_output(crate::tf!("DIMSTYLE: '{}' created.", name).as_ref());
}
}
"SET" | "S" => {
@ -896,9 +896,9 @@ impl OpenCADStudio {
ds.dimfxl = val;
}
_ => {
self.command_line.push_error(&format!(
self.command_line.push_error(crate::tf!(
"DIMSTYLE: unknown property '{}'. Try: dimtxt dimasz dimdli dimexo dimexe dimgap dimscale dimlfac dimdle dimcen dimtsz", prop
));
).as_ref());
return Some(Task::none());
}
}
@ -906,16 +906,16 @@ impl OpenCADStudio {
self.tabs[i].scene
.invalidate_dim_style_dependencies(&style_name);
self.commit_dim_style_undo(i, undo);
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"DIMSTYLE: '{style_name}'.{prop} = {val:.3}"
));
).as_ref());
} else {
self.command_line
.push_error(&format!("DIMSTYLE: '{}' not found.", style_name));
.push_error(crate::tf!("DIMSTYLE: '{}' not found.", style_name).as_ref());
}
} else {
self.command_line
.push_error("Usage: DIMSTYLE SET <name> <property> <value>");
.push_error(crate::t!("Usage: DIMSTYLE SET <name> <property> <value>").as_ref());
}
}
_ => {
@ -956,28 +956,28 @@ impl OpenCADStudio {
let current = &self.tabs[i].active_mleader_style;
if styles.is_empty() {
self.command_line
.push_output(&format!("MLeader styles: (none) active: {current}"));
.push_output(crate::tf!("MLeader styles: (none) active: {current}").as_ref());
} else {
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"MLeader styles: {} active: {current}",
styles.join(", ")
));
).as_ref());
}
}
"NEW" | "N" => {
let name = parts.get(1).map(|s| s.trim()).unwrap_or("").to_string();
if name.is_empty() {
self.command_line
.push_error("Usage: MLEADERSTYLE NEW <name>");
.push_error(crate::t!("Usage: MLEADERSTYLE NEW <name>").as_ref());
} else {
let already_exists = self.tabs[i].scene.document.objects.values().any(
|o| matches!(o, ObjectType::MultiLeaderStyle(s) if s.name == name),
);
if already_exists {
self.command_line.push_error(&format!(
self.command_line.push_error(crate::tf!(
"MLEADERSTYLE: '{}' already exists.",
name
));
).as_ref());
} else {
let handle = self.tabs[i].scene.document.allocate_handle();
let mut style = MultiLeaderStyle::new(&name);
@ -990,7 +990,7 @@ impl OpenCADStudio {
self.push_undo_snapshot(i, "MLEADERSTYLE NEW");
self.tabs[i].dirty = true;
self.command_line
.push_output(&format!("MLEADERSTYLE: '{}' created.", name));
.push_output(crate::tf!("MLEADERSTYLE: '{}' created.", name).as_ref());
}
}
}
@ -1032,52 +1032,52 @@ impl OpenCADStudio {
s.landing_gap = val;
}
_ => {
self.command_line.push_error(&format!(
self.command_line.push_error(crate::tf!(
"MLEADERSTYLE: unknown property '{}'. Try: text_height arrowhead_size landing_distance landing_gap", prop
));
).as_ref());
return Some(Task::none());
}
}
self.push_undo_snapshot(i, "MLEADERSTYLE SET");
self.tabs[i].dirty = true;
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"MLEADERSTYLE: '{style_name}'.{prop} = {val:.3}"
));
).as_ref());
} else {
self.command_line.push_error(&format!(
self.command_line.push_error(crate::tf!(
"MLEADERSTYLE: '{}' not found.",
style_name
));
).as_ref());
}
} else {
self.command_line
.push_error("Usage: MLEADERSTYLE SET <name> <property> <value>");
.push_error(crate::t!("Usage: MLEADERSTYLE SET <name> <property> <value>").as_ref());
}
}
"CURRENT" | "C" | "ACTIVE" => {
let name = parts.get(1).map(|s| s.trim()).unwrap_or("").to_string();
if name.is_empty() {
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"Current MLeader style: {}",
self.tabs[i].active_mleader_style
));
).as_ref());
} else {
let exists = name == "Standard" || self.tabs[i].scene.document.objects.values()
.any(|o| matches!(o, ObjectType::MultiLeaderStyle(s) if s.name == name));
if exists {
self.tabs[i].active_mleader_style = name.clone();
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"MLEADERSTYLE: current style set to '{name}'."
));
).as_ref());
} else {
self.command_line
.push_error(&format!("MLEADERSTYLE: '{}' not found.", name));
.push_error(crate::tf!("MLEADERSTYLE: '{}' not found.", name).as_ref());
}
}
}
_ => {
self.command_line.push_info(
"Usage: MLEADERSTYLE LIST | NEW <name> | SET <name> <prop> <val> | CURRENT [<name>]"
crate::t!("Usage: MLEADERSTYLE LIST | NEW <name> | SET <name> <prop> <val> | CURRENT [<name>]").as_ref()
);
}
}
@ -1117,10 +1117,10 @@ impl OpenCADStudio {
})
.collect();
if styles.is_empty() {
self.command_line.push_output("No text styles defined.");
self.command_line.push_output(crate::t!("No text styles defined.").as_ref());
} else {
self.command_line
.push_output(&format!("Text styles: {}", styles.join(" | ")));
.push_output(crate::tf!("Text styles: {}", styles.join(" | ")).as_ref());
}
}
"SET" | "S" => {
@ -1128,20 +1128,20 @@ impl OpenCADStudio {
let name = parts.get(1).map(|s| s.trim()).unwrap_or("");
if self.tabs[i].scene.document.text_styles.get(name).is_some() {
self.command_line
.push_output(&format!("{prefix}: active style set to '{name}'."));
.push_output(crate::tf!("{prefix}: active style set to '{name}'.").as_ref());
} else {
self.command_line
.push_error(&format!("{prefix}: style '{name}' not found."));
.push_error(crate::tf!("{prefix}: style '{name}' not found.").as_ref());
}
}
"NEW" | "N" => {
let name = parts.get(1).map(|s| s.trim()).unwrap_or("").to_string();
if name.is_empty() {
self.command_line
.push_error(&format!("Usage: {prefix} NEW <name>"));
.push_error(crate::tf!("Usage: {prefix} NEW <name>").as_ref());
} else if self.tabs[i].scene.document.text_styles.contains(&name) {
self.command_line
.push_error(&format!("{prefix}: style '{name}' already exists."));
.push_error(crate::tf!("{prefix}: style '{name}' already exists.").as_ref());
} else {
let undo = self.begin_text_style_undo(
i,
@ -1153,7 +1153,7 @@ impl OpenCADStudio {
self.tabs[i].dirty = true;
self.commit_text_style_undo(i, undo);
self.command_line
.push_output(&format!("{prefix}: style '{name}' created."));
.push_output(crate::tf!("{prefix}: style '{name}' created.").as_ref());
}
}
"FONT" | "F" => {
@ -1162,7 +1162,7 @@ impl OpenCADStudio {
let font = parts.get(2).map(|s| s.trim()).unwrap_or("").to_string();
if style_name.is_empty() || font.is_empty() {
self.command_line
.push_error(&format!("Usage: {prefix} FONT <style> <font_file>"));
.push_error(crate::tf!("Usage: {prefix} FONT <style> <font_file>").as_ref());
} else {
let undo = self.begin_text_style_undo(
i,
@ -1178,12 +1178,12 @@ impl OpenCADStudio {
.scene
.invalidate_text_style_dependencies(&style_name);
self.commit_text_style_undo(i, undo);
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"{prefix}: '{style_name}' font set to '{font}'."
));
).as_ref());
} else {
self.command_line
.push_error(&format!("{prefix}: style '{style_name}' not found."));
.push_error(crate::tf!("{prefix}: style '{style_name}' not found.").as_ref());
}
}
}
@ -1206,17 +1206,17 @@ impl OpenCADStudio {
.scene
.invalidate_text_style_dependencies(&style_name);
self.commit_text_style_undo(i, undo);
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"{prefix}: '{style_name}' width factor set to {factor:.3}."
));
).as_ref());
} else {
self.command_line.push_error(&format!(
self.command_line.push_error(crate::tf!(
"{prefix}: style '{style_name}' not found."
));
).as_ref());
}
} else {
self.command_line
.push_error(&format!("Usage: {prefix} WIDTH <style> <factor>"));
.push_error(crate::tf!("Usage: {prefix} WIDTH <style> <factor>").as_ref());
}
}
"OBLIQUE" => {
@ -1238,24 +1238,24 @@ impl OpenCADStudio {
.scene
.invalidate_text_style_dependencies(&style_name);
self.commit_text_style_undo(i, undo);
self.command_line.push_output(&format!(
self.command_line.push_output(crate::tf!(
"{prefix}: '{style_name}' oblique angle set to {deg:.1}°."
));
).as_ref());
} else {
self.command_line.push_error(&format!(
self.command_line.push_error(crate::tf!(
"{prefix}: style '{style_name}' not found."
));
).as_ref());
}
} else {
self.command_line.push_error(&format!(
self.command_line.push_error(crate::tf!(
"Usage: {prefix} OBLIQUE <style> <angle_degrees>"
));
).as_ref());
}
}
_ => {
self.command_line.push_info(&format!(
self.command_line.push_info(crate::tf!(
"Usage: {prefix} LIST | NEW <name> | FONT <style> <file> | WIDTH <style> <factor> | OBLIQUE <style> <angle>"
));
).as_ref());
}
}
}