feat(locale): localize full interface

This commit is contained in:
Hakan Seven committed 2026-08-02 22:09:25 +03:00
1 parent b90b3e3ecf
commit 3e6693b93f
205 files changed
+32369 -3810

No files matched your search

+15 -5
View File
@@ -2,6 +2,7 @@
// Press Enter to close and calculate.
use glam::DVec3;
use crate::t;
use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel;
@@ -23,12 +24,14 @@ impl CadCommand for AreaCommand {
fn prompt(&self) -> String {
if self.points.is_empty() {
"AREA Specify first corner point (Enter to cancel):".into()
t!("AREA Specify first corner point (Enter to cancel):").into_owned()
} else {
format!(
"AREA Specify next point ({} picked, Enter to calculate):",
self.points.len()
let n = self.points.len();
t!(
"AREA Specify next point (%{n} picked, Enter to calculate):",
n = n
)
.into_owned()
}
}
@@ -56,7 +59,14 @@ impl CadCommand for AreaCommand {
perimeter += (self.points[(idx + 1) % n] - self.points[idx]).length();
}
let area = (area_sum * 0.5).abs();
let msg = format!("Area = {area:.4}, Perimeter = {perimeter:.4}");
let area_s = format!("{area:.4}");
let perimeter_s = format!("{perimeter:.4}");
let msg = t!(
"Area = %{area}, Perimeter = %{perimeter}",
area = area_s,
perimeter = perimeter_s
)
.into_owned();
CmdResult::Measurement(msg)
}
+19 -5
View File
@@ -1,6 +1,7 @@
// DIST command — measure distance and angle between two picked points.
use glam::DVec3;
use crate::t;
use crate::command::{CadCommand, CmdResult};
use crate::scene::model::wire_model::WireModel;
@@ -25,9 +26,9 @@ impl CadCommand for DistCommand {
fn prompt(&self) -> String {
if self.first.is_none() {
"DIST Specify first point:".into()
t!("DIST Specify first point:").into_owned()
} else {
"DIST Specify second point:".into()
t!("DIST Specify second point:").into_owned()
}
}
@@ -45,9 +46,22 @@ impl CadCommand for DistCommand {
let dist_xy = dx.hypot(dy);
let angle_z = dz.atan2(dist_xy).to_degrees();
let msg = format!(
"Distance = {dist:.4}, Angle in XY Plane = {angle_xy:.4}°, Angle from XY Plane = {angle_z:.4}°\n Delta X = {dx:.4}, Delta Y = {dy:.4}, Delta Z = {dz:.4}",
);
let dist_s = format!("{dist:.4}");
let angle_xy_s = format!("{angle_xy:.4}");
let angle_z_s = format!("{angle_z:.4}");
let dx_s = format!("{dx:.4}");
let dy_s = format!("{dy:.4}");
let dz_s = format!("{dz:.4}");
let msg = t!(
"Distance = %{dist}, Angle in XY Plane = %{angle_xy}°, Angle from XY Plane = %{angle_z}°\n Delta X = %{dx}, Delta Y = %{dy}, Delta Z = %{dz}",
dist = dist_s,
angle_xy = angle_xy_s,
angle_z = angle_z_s,
dx = dx_s,
dy = dy_s,
dz = dz_s,
)
.into_owned();
CmdResult::Measurement(msg)
} else {
self.first = Some(pt);
+5 -4
View File
@@ -7,6 +7,7 @@ use acadrust::entities::Point as PointEnt;
use acadrust::types::Vector3;
use acadrust::{EntityType, Handle};
use glam::DVec3;
use crate::t;
use crate::command::{CadCommand, CmdResult};
@@ -33,9 +34,9 @@ impl CadCommand for DivideCommand {
fn prompt(&self) -> String {
if self.target.is_none() {
"DIVIDE Select object to divide:".into()
t!("DIVIDE Select object to divide:").into_owned()
} else {
"DIVIDE Enter number of segments:".into()
t!("DIVIDE Enter number of segments:").into_owned()
}
}
@@ -102,9 +103,9 @@ impl CadCommand for MeasureCommand {
fn prompt(&self) -> String {
if self.target.is_none() {
"MEASURE Select object to measure:".into()
t!("MEASURE Select object to measure:").into_owned()
} else {
"MEASURE Specify segment length:".into()
t!("MEASURE Specify segment length:").into_owned()
}
}
+12 -2
View File
@@ -1,6 +1,7 @@
// ID command — report coordinates of a picked point.
use glam::DVec3;
use crate::t;
use crate::command::{CadCommand, CmdResult};
@@ -18,7 +19,7 @@ impl CadCommand for IdCommand {
}
fn prompt(&self) -> String {
"ID Specify point:".into()
t!("ID Specify point:").into_owned()
}
fn on_point(&mut self, pt: DVec3) -> CmdResult {
@@ -26,7 +27,16 @@ impl CadCommand for IdCommand {
let x = pt.x;
let y = pt.y;
let z = pt.z;
let msg = format!("X = {x:.4}, Y = {y:.4}, Z = {z:.4}");
let x_s = format!("{x:.4}");
let y_s = format!("{y:.4}");
let z_s = format!("{z:.4}");
let msg = t!(
"X = %{x}, Y = %{y}, Z = %{z}",
x = x_s,
y = y_s,
z = z_s
)
.into_owned();
CmdResult::Measurement(msg)
}
+48 -19
View File
@@ -16,6 +16,7 @@
use acadrust::{EntityType, Handle};
use glam::DVec3;
use crate::t;
use crate::command::{CadCommand, CmdResult};
use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -112,9 +113,20 @@ impl MeasureGeomCommand {
let dy = delta.y; // drawing plane is world XY
let dz = delta.z; // elevation
let angle_xy = dy.atan2(dx).to_degrees();
format!(
"Distance = {dist:.4}, Angle in XY Plane = {angle_xy:.4}°\n Delta X = {dx:.4}, Delta Y = {dy:.4}, Delta Z = {dz:.4}",
let dist_s = format!("{dist:.4}");
let angle_xy_s = format!("{angle_xy:.4}");
let dx_s = format!("{dx:.4}");
let dy_s = format!("{dy:.4}");
let dz_s = format!("{dz:.4}");
t!(
"Distance = %{dist}, Angle in XY Plane = %{angle_xy}°\n Delta X = %{dx}, Delta Y = %{dy}, Delta Z = %{dz}",
dist = dist_s,
angle_xy = angle_xy_s,
dx = dx_s,
dy = dy_s,
dz = dz_s,
)
.into_owned()
}
/// AREA readout: shoelace area (f64, relative to first vertex) + perimeter.
@@ -130,7 +142,14 @@ impl MeasureGeomCommand {
perimeter += (points[(idx + 1) % n] - points[idx]).length();
}
let area = (area_sum * 0.5).abs();
format!("Area = {area:.4}, Perimeter = {perimeter:.4}")
let area_s = format!("{area:.4}");
let perimeter_s = format!("{perimeter:.4}");
t!(
"Area = %{area}, Perimeter = %{perimeter}",
area = area_s,
perimeter = perimeter_s
)
.into_owned()
}
/// ANGLE readout: angle at `vertex` between the rays to `a` and `b`.
@@ -140,11 +159,12 @@ impl MeasureGeomCommand {
let la = va.length();
let lb = vb.length();
if la == 0.0 || lb == 0.0 {
return "Angle = 0.0000° (degenerate rays)".to_string();
return t!("Angle = 0.0000° (degenerate rays)").into_owned();
}
let cos = (va.dot(vb) / (la * lb)).clamp(-1.0, 1.0);
let angle = cos.acos().to_degrees();
format!("Angle = {angle:.4}°")
let angle_s = format!("{angle:.4}");
t!("Angle = %{angle}°", angle = angle_s).into_owned()
}
}
@@ -156,31 +176,33 @@ impl CadCommand for MeasureGeomCommand {
fn prompt(&self) -> String {
match self.mode {
Mode::Choose => {
"MEASUREGEOM Enter an option [Distance/Radius/Angle/ARea]:".into()
t!("MEASUREGEOM Enter an option [Distance/Radius/Angle/ARea]:").into_owned()
}
Mode::Distance => {
if self.points.is_empty() {
"MEASUREGEOM Specify first point:".into()
t!("MEASUREGEOM Specify first point:").into_owned()
} else {
"MEASUREGEOM Specify second point:".into()
t!("MEASUREGEOM Specify second point:").into_owned()
}
}
Mode::Area => {
if self.points.is_empty() {
"MEASUREGEOM Specify first corner point (Enter to cancel):".into()
t!("MEASUREGEOM Specify first corner point (Enter to cancel):").into_owned()
} else {
format!(
"MEASUREGEOM Specify next point ({} picked, Enter to calculate):",
self.points.len()
let n = self.points.len();
t!(
"MEASUREGEOM Specify next point (%{n} picked, Enter to calculate):",
n = n
)
.into_owned()
}
}
Mode::Angle => match self.points.len() {
0 => "MEASUREGEOM Specify vertex point:".into(),
1 => "MEASUREGEOM Specify first ray point:".into(),
_ => "MEASUREGEOM Specify second ray point:".into(),
0 => t!("MEASUREGEOM Specify vertex point:").into_owned(),
1 => t!("MEASUREGEOM Specify first ray point:").into_owned(),
_ => t!("MEASUREGEOM Specify second ray point:").into_owned(),
},
Mode::Radius => "MEASUREGEOM Select arc or circle:".into(),
Mode::Radius => t!("MEASUREGEOM Select arc or circle:").into_owned(),
}
}
@@ -223,9 +245,16 @@ impl CadCommand for MeasureGeomCommand {
match self.picked.as_ref().and_then(Self::radius_of) {
Some(radius) => {
let diameter = radius * 2.0;
CmdResult::Measurement(format!(
"Radius = {radius:.4}, Diameter = {diameter:.4}"
))
let radius_s = format!("{radius:.4}");
let diameter_s = format!("{diameter:.4}");
CmdResult::Measurement(
t!(
"Radius = %{radius}, Diameter = %{diameter}",
radius = radius_s,
diameter = diameter_s
)
.into_owned(),
)
}
// Picked something that is not a circle or arc — keep prompting.
None => CmdResult::NeedPoint,