Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use locale for selecting language #6

Closed
tverra opened this issue Jul 10, 2020 · 2 comments
Closed

Use locale for selecting language #6

tverra opened this issue Jul 10, 2020 · 2 comments

Comments

@tverra
Copy link
Contributor

tverra commented Jul 10, 2020

When handling dates in Flutter, I'm used to using the buildt-in Localizations.localeOf(context).languageCode to get the correct format on dates and so on. An example of formatting dates: DateFormat.yMMMMd(Localizations.localeOf(context).languageCode).format(value). The date is then formatted to to match the language of the device. I'd like to be able to do the same with this package, but it doesn't accept a language code string. Instead I'd have to do something like this;

DateTimePickerLocale dateTimePickerLocale;

switch (locale.languageCode) {
  case 'nb':
    dateTimePickerLocale = DateTimePickerLocale.no_nb;
    break;
  case ...

  default:
    dateTimePickerLocale = DateTimePickerLocale.en_us;
    break;
}

This is not a great solution, since it would have to be updated every time a language is added. It would be a much more flexible solution to let the showSimpleDatePicker method accept a language code string instead.

@kfiross
Copy link
Owner

kfiross commented Aug 13, 2020

Hi,
Thanks for the good suggestion, It will be added soon.

@kfiross
Copy link
Owner

kfiross commented Aug 28, 2020

Added It now, issue closed.

@kfiross kfiross closed this as completed Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants