xgfe / react-native-datepicker

react native datePicker component for both Android and IOS, useing DatePikcerAndroid, TimePickerAndroid and DatePickerIOS
MIT License
2.12k stars 727 forks source link

[react-native-paper-dates] The locale en is not registered, see README!, key: typeInDate #473

Open vinayzerozilla opened 8 months ago

vinayzerozilla commented 8 months ago

Issue

Giving the warning [react-native-paper-dates] The locale en is not registered, see README!, key: typeInDate

Expected Behavior

it shouldn't give warning after the setting the locale also

Code

<DatePickerModal
         locale="en" 
          mode="single"
          visible={open}
          onDismiss={onDismissSingle}
          date={props.date}
          onConfirm={onConfirmSingle}
        />

Environment

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

image

pfiwinf commented 8 months ago

Got the same issue

fbpatel003 commented 8 months ago

I have same issue !

pfiwinf commented 8 months ago

found this:

https://web-ridge.github.io/react-native-paper-dates/docs/intro

Scroll down to Custom, you can register your own locale, seems like a workaround. With this it worked for me.

UIT19521334 commented 5 months ago

Can you explain more about the way to fix the warning

pfiwinf commented 5 months ago

I just registered my preferred language at the "Custom" part in https://web-ridge.github.io/react-native-paper-dates/docs/intro.

Like:

import { registerTranslation } from 'react-native-paper-dates'
registerTranslation('pl', {
  save: 'Save',
  selectSingle: 'Select date',
  selectMultiple: 'Select dates',
  selectRange: 'Select period',
  notAccordingToDateFormat: (inputFormat) =>
    `Date format must be ${inputFormat}`,
  mustBeHigherThan: (date) => `Must be later then ${date}`,
  mustBeLowerThan: (date) => `Must be earlier then ${date}`,
  mustBeBetween: (startDate, endDate) =>
    `Must be between ${startDate} - ${endDate}`,
  dateIsDisabled: 'Day is not allowed',
  previous: 'Previous',
  next: 'Next',
  typeInDate: 'Type in date',
  pickDateFromCalendar: 'Pick date from calendar',
  close: 'Close',
})

And here i just added my own translation.

UIT19521334 commented 5 months ago

I'm really happy because I successfully resolved the issue that was causing a warning. It feels great to have everything working smoothly now. Thanks so much for your help!

Nicholson85 commented 5 months ago

I think the problem stems from the documentation using en-gb as an example.

Replacing registerTranslation("en-GB", enGB); with registerTranslation("en", enGB); fixes the problem for me and doesnt require you to implement your own custom localisation.