i18n: shipped components read their copy from the catalog
Select's default placeholder, the clear, close, remove and unpin tooltips, the completion menu's empty line and the size sample showed English under zh-CN. A source test now fails on any fixed English literal in them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
1b5fb07cda
commit
d05b1b78ca
11 files changed
+86
-15
No files matched your search
+2
-1
@@ -4,6 +4,7 @@ use gpui::{
|
||||
};
|
||||
|
||||
use super::TextInput;
|
||||
use crate::i18n;
|
||||
use crate::{
|
||||
buttons::IconButton,
|
||||
primitives::{Icon, IconName},
|
||||
@@ -148,7 +149,7 @@ impl RenderOnce for Input {
|
||||
frame.child(
|
||||
IconButton::new(("input-clear", clear_id), IconName::CircleX)
|
||||
.size(ControlSize::Sm)
|
||||
.tooltip("Clear")
|
||||
.tooltip(i18n::text(cx, "input.clear", &[]))
|
||||
.on_click(move |_, window, cx| {
|
||||
state.update(cx, |input, cx| input.set_text("", cx));
|
||||
window.focus(&state.read(cx).focus().clone(), cx);
|
||||
|
||||
+7
-5
@@ -251,7 +251,7 @@ pub struct Select {
|
||||
id: ElementId,
|
||||
choices: Vec<Choice>,
|
||||
selected: Option<SharedString>,
|
||||
placeholder: SharedString,
|
||||
placeholder: Option<SharedString>,
|
||||
label: Option<SharedString>,
|
||||
size: ControlSize,
|
||||
disabled: bool,
|
||||
@@ -264,7 +264,7 @@ impl Select {
|
||||
id: id.into(),
|
||||
choices: choices.into_iter().collect(),
|
||||
selected: None,
|
||||
placeholder: SharedString::from("Choose…"),
|
||||
placeholder: None,
|
||||
label: None,
|
||||
size: ControlSize::default(),
|
||||
disabled: false,
|
||||
@@ -284,7 +284,7 @@ impl Select {
|
||||
}
|
||||
|
||||
pub fn placeholder(mut self, text: impl Into<SharedString>) -> Self {
|
||||
self.placeholder = text.into();
|
||||
self.placeholder = Some(text.into());
|
||||
self
|
||||
}
|
||||
|
||||
@@ -326,6 +326,8 @@ impl RenderOnce for Select {
|
||||
.as_ref()
|
||||
.and_then(|value| choices.iter().find(|choice| choice.value == *value))
|
||||
.cloned();
|
||||
let placeholder =
|
||||
(self.placeholder.clone()).unwrap_or_else(|| i18n::text(cx, "select.placeholder", &[]));
|
||||
let colors = &cx.theme().colors;
|
||||
let trigger = field_button(
|
||||
self.id.clone(),
|
||||
@@ -336,7 +338,7 @@ impl RenderOnce for Select {
|
||||
cx,
|
||||
)
|
||||
.role(Role::ComboBox)
|
||||
.aria_placeholder(self.placeholder.clone())
|
||||
.aria_placeholder(placeholder.clone())
|
||||
.when_some(self.label.clone(), |trigger, label| {
|
||||
trigger.aria_label(label)
|
||||
})
|
||||
@@ -361,7 +363,7 @@ impl RenderOnce for Select {
|
||||
)
|
||||
.child(field_text(
|
||||
shown.map(|choice| choice.label),
|
||||
self.placeholder,
|
||||
placeholder,
|
||||
self.disabled,
|
||||
cx,
|
||||
))
|
||||
|
||||
Reference in new issue
Block a user