@@ -30,7 +30,7 @@ use crate::styles::components::{HighlightColor, IntrinsicPadding, OutlineColor,
30
30
use crate :: utils:: ModifiersExt ;
31
31
use crate :: widget:: { Callback , EventHandling , Widget , HANDLED , IGNORED } ;
32
32
use crate :: window:: KeyEvent ;
33
- use crate :: { ConstraintLimit , FitMeasuredSize , Lazy } ;
33
+ use crate :: { ConstraintLimit , FitMeasuredSize , Lazy , MaybeLocalized } ;
34
34
35
35
const CURSOR_BLINK_DURATION : Duration = Duration :: from_millis ( 500 ) ;
36
36
@@ -40,7 +40,7 @@ pub struct Input<Storage = String> {
40
40
/// The value of this widget.
41
41
pub value : Dynamic < Storage > ,
42
42
/// The placeholder text to display when no value is present.
43
- pub placeholder : Value < String > ,
43
+ pub placeholder : Value < MaybeLocalized > ,
44
44
mask_symbol : Value < CowString > ,
45
45
mask : CowString ,
46
46
on_key : Option < Callback < KeyEvent , EventHandling > > ,
@@ -129,7 +129,7 @@ where
129
129
130
130
/// Sets the `placeholder` text, which is displayed when the field has an
131
131
/// empty value.
132
- pub fn placeholder ( mut self , placeholder : impl IntoValue < String > ) -> Self {
132
+ pub fn placeholder ( mut self , placeholder : impl IntoValue < MaybeLocalized > ) -> Self {
133
133
self . placeholder = placeholder. into_value ( ) ;
134
134
self
135
135
}
@@ -607,7 +607,11 @@ where
607
607
}
608
608
609
609
let placeholder_color = context. theme ( ) . surface . on_color_variant ;
610
- let placeholder = self . placeholder . map ( |placeholder| context. gfx . measure_text ( Text :: new ( placeholder, placeholder_color) ) ) ;
610
+ let placeholder = self . placeholder . map ( |placeholder| {
611
+ let text = placeholder. localize ( context) . to_string ( ) ;
612
+
613
+ context. gfx . measure_text ( Text :: new ( & text, placeholder_color) )
614
+ } ) ;
611
615
( bytes, context. gfx . measure_text ( text) , placeholder)
612
616
} ) ;
613
617
self . cache = Some ( CachedLayout {
0 commit comments