Skip to content

Commit dbb981d

Browse files
Added locale support.
1 parent f905ae0 commit dbb981d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/date_picker_timeline.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class DatePickerTimeline extends StatefulWidget {
1515
DateTime currentDate;
1616
DateChangeListener onDateChange;
1717
int daysCount;
18+
String locale;
1819

1920
// Creates the DatePickerTimeline Widget
2021
DatePickerTimeline(
@@ -28,6 +29,7 @@ class DatePickerTimeline extends StatefulWidget {
2829
this.selectionColor = AppColors.defaultSelectionColor,
2930
this.daysCount = 50000,
3031
this.onDateChange,
32+
this.locale,
3133
}) : super(key: key);
3234

3335
@override
@@ -54,6 +56,7 @@ class _DatePickerState extends State<DatePickerTimeline> {
5456
monthTextStyle: widget.monthTextStyle,
5557
dateTextStyle: widget.dateTextStyle,
5658
dayTextStyle: widget.dayTextStyle,
59+
locale: widget.locale,
5760
selectionColor:
5861
isSelected ? widget.selectionColor : Colors.transparent,
5962
onDateSelected: (selectedDate) {

lib/date_widget.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ class DateWidget extends StatelessWidget {
1414
final TextStyle monthTextStyle, dayTextStyle, dateTextStyle;
1515
final Color selectionColor;
1616
final DateSelectionCallback onDateSelected;
17+
final String locale;
1718

1819
DateWidget(
1920
{@required this.date,
2021
@required this.monthTextStyle,
2122
@required this.dayTextStyle,
2223
@required this.dateTextStyle,
2324
@required this.selectionColor,
24-
this.onDateSelected});
25+
this.onDateSelected,
26+
this.locale,
27+
});
2528

2629
@override
2730
Widget build(BuildContext context) {
@@ -39,11 +42,11 @@ class DateWidget extends StatelessWidget {
3942
mainAxisAlignment: MainAxisAlignment.center,
4043
crossAxisAlignment: CrossAxisAlignment.center,
4144
children: <Widget>[
42-
Text(new DateFormat("MMM").format(date).toUpperCase(), // Month
45+
Text(new DateFormat("MMM", locale ?? 'en').format(date).toUpperCase(), // Month
4346
style: monthTextStyle),
4447
Text(date.day.toString(), // Date
4548
style: dateTextStyle),
46-
Text(new DateFormat("E").format(date).toUpperCase(), // WeekDay
49+
Text(new DateFormat("E", locale ?? 'en').format(date).toUpperCase(), // WeekDay
4750
style: dayTextStyle)
4851
],
4952
),

0 commit comments

Comments
 (0)