react-native-datepicker icon indicating copy to clipboard operation
react-native-datepicker copied to clipboard

Date string ignores the locale

Open michaeleisel opened this issue 7 years ago • 8 comments

Issue

When I set the locale of the date picker to "fr", I see that the options within the UIDatePicker have changed to French. However, the date string for that date is still in English. I'm using the "LL" and "LT" format strings.

Expected Behavior

The date string should have the French locale when I specify "fr" as the locale.

Code


Environment

  1. react-native -v:
  2. node -v:
  3. npm -v:
  4. yarn --version:
  5. target platform: Android | iOS
  6. operating system:

michaeleisel avatar Apr 27 '18 02:04 michaeleisel

can we have some disclosure here? I noticed in your code you only use the prop locale for the DatePickerIOS, can't it be added to android?

FernandoCCNunes avatar May 11 '18 09:05 FernandoCCNunes

I never tried it on Android

michaeleisel avatar May 16 '18 03:05 michaeleisel

Same issue here

VanessaChu avatar May 28 '18 20:05 VanessaChu

Was this ever solved?

VanessaChu avatar May 28 '18 21:05 VanessaChu

Same issue

Spoutnik97 avatar Jun 20 '18 11:06 Spoutnik97

Same issue

Revocsid avatar Sep 05 '18 09:09 Revocsid

This actually can be overcome by using "getDateStr" instead of using "date". getDateStr takes Date as an input, you can use that input with your favorite library (eg momentjs) to convert the time to desired format and locale(language).

esdotzed avatar Jul 31 '19 07:07 esdotzed

The only way language works for me is like this: import moment from "moment"; if (getPrimaryLanguage() === "zh") {require("moment/locale/zh-cn")}; Define getPrimaryLanguage() yourself use library like i18njs...

esdotzed avatar Jul 31 '19 09:07 esdotzed