0

Anyone can share them a workaround for this bug, I also need to implement the Localization for Datepicker, I implementing the Localization in this link https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/localization/text?tabs=windows

Then Translate and Change the Culture using this

public void SetLocale(CultureInfo ci)
{
            Thread.CurrentThread.CurrentCulture = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            Console.WriteLine("CurrentCulture set: " + ci.Name);
 }

But the app still using the Device OS culture setting.

I also try Custom Renderer.

public class CustomDatePickerRenderer : DatePickerRenderer
{
    public CustomDatePickerRenderer(Context context) :base(context)
    {            
    }

    protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.DatePicker> e)
    {
        base.OnElementChanged(e);
        Locale locale = new Locale("ARA");
        Control.TextLocale = locale;
        Resources.Configuration.SetLocale(locale);
        Resources.Configuration.Locale = locale;
        Resources.Configuration.SetLayoutDirection(locale);
    }

}
parpar
  • 103
  • 1
  • 17
  • Not sure which "bug" you are referring to, maybe this one?: https://stackoverflow.com/questions/45871800/set-android-datepicker-title-language/45889476#45889476 – SushiHangover Sep 07 '19 at 23:34
  • var dialog = new DatePickerDialog(this); dialog.Show(); SetHeaderMonthDay(dialog, Locale.Korean); Where I can get the "This" inside my DatepickerRenderer? – parpar Sep 08 '19 at 00:42
  • @parpar The `this` in the sample represents the `Context`. You can get the context from the `CustomDatePickerRenderer` constructor. Save it into a private field and use it whenever you need later. – pinedax Sep 08 '19 at 21:40
  • @SushiHangover can share the link where I can get the date_picker_header_date.xml ? thanks – parpar Sep 09 '19 at 08:26
  • @parpar, It seems that it depend on system language, can not change datepicker title language by custom render. – Cherry Bu - MSFT Sep 11 '19 at 07:34

0 Answers0