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