forked from 1b-agent/opencadstudio-upstream
fix(i18n): localize linetype inheritance
This commit is contained in:
1 parent
8c0af9d584
commit
3024869de0
3 files changed
+21
-6
No files matched your search
+13
-2
@@ -44,12 +44,23 @@ pub struct LinetypeItem {
|
|||||||
pub art: String,
|
pub art: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn linetype_display_name(name: &str) -> String {
|
||||||
|
if name.is_empty() || name.eq_ignore_ascii_case("ByLayer") {
|
||||||
|
crate::t!("ByLayer").into_owned()
|
||||||
|
} else if name.eq_ignore_ascii_case("ByBlock") {
|
||||||
|
crate::t!("ByBlock").into_owned()
|
||||||
|
} else {
|
||||||
|
name.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for LinetypeItem {
|
impl fmt::Display for LinetypeItem {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let name = linetype_display_name(&self.name);
|
||||||
if self.art.is_empty() {
|
if self.art.is_empty() {
|
||||||
write!(f, "{}", self.name)
|
write!(f, "{name}")
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{} {}", self.name, self.art)
|
write!(f, "{name} {}", self.art)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use iced::{Background, Border, Color, Element, Fill, Length, Padding, Theme};
|
|||||||
use crate::app::Message;
|
use crate::app::Message;
|
||||||
use crate::modules::{CadModule, IconKind, RibbonGroup, RibbonItem};
|
use crate::modules::{CadModule, IconKind, RibbonGroup, RibbonItem};
|
||||||
use crate::plugin::all_ribbon_modules;
|
use crate::plugin::all_ribbon_modules;
|
||||||
use crate::ui::properties::{lw_options, LinetypeItem};
|
use crate::ui::properties::{linetype_display_name, lw_options, LinetypeItem};
|
||||||
|
|
||||||
mod widgets;
|
mod widgets;
|
||||||
use widgets::{StyleContext, *};
|
use widgets::{StyleContext, *};
|
||||||
@@ -1182,7 +1182,7 @@ impl Ribbon {
|
|||||||
let is_cur = lt.name == *active_lt;
|
let is_cur = lt.name == *active_lt;
|
||||||
let check: Element<'_, Message> =
|
let check: Element<'_, Message> =
|
||||||
crate::ui::icons::themed_check_cell(is_cur);
|
crate::ui::icons::themed_check_cell(is_cur);
|
||||||
let name_col = text(lt.name.clone())
|
let name_col = text(linetype_display_name(<.name))
|
||||||
.size(11)
|
.size(11)
|
||||||
.style(move |theme: &Theme| iced::widget::text::Style {
|
.style(move |theme: &Theme| iced::widget::text::Style {
|
||||||
color: (!is_cur).then_some(
|
color: (!is_cur).then_some(
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use crate::app::Message;
|
|||||||
use crate::modules::{IconKind, ModuleEvent, RibbonItem, StyleKey, ToolDef};
|
use crate::modules::{IconKind, ModuleEvent, RibbonItem, StyleKey, ToolDef};
|
||||||
use crate::ui::wrap_bar::PosReport;
|
use crate::ui::wrap_bar::PosReport;
|
||||||
use crate::ui::icons;
|
use crate::ui::icons;
|
||||||
use crate::ui::properties::{acad_color_display, LwItem};
|
use crate::ui::properties::{acad_color_display, linetype_display_name, LwItem};
|
||||||
use crate::t;
|
use crate::t;
|
||||||
|
|
||||||
use super::LayerInfo;
|
use super::LayerInfo;
|
||||||
@@ -998,7 +998,11 @@ pub(super) fn render_large<'a>(
|
|||||||
PROP_COLOR_ID,
|
PROP_COLOR_ID,
|
||||||
Some(color_swatch),
|
Some(color_swatch),
|
||||||
);
|
);
|
||||||
let lt_row = prop_row(active_linetype.to_string(), PROP_LINETYPE_ID, None);
|
let lt_row = prop_row(
|
||||||
|
linetype_display_name(active_linetype),
|
||||||
|
PROP_LINETYPE_ID,
|
||||||
|
None,
|
||||||
|
);
|
||||||
let lw_row = prop_row(LwItem(active_lineweight).to_string(), PROP_LW_ID, None);
|
let lw_row = prop_row(LwItem(active_lineweight).to_string(), PROP_LW_ID, None);
|
||||||
|
|
||||||
let combos = container(
|
let combos = container(
|
||||||
|
|||||||
Reference in new issue
Block a user