Liu Yanbo 6 роки тому
батько
коміт
4841f1e280
5 змінених файлів з 141 додано та 55 видалено
  1. 2 1
      CHANGELOG.md
  2. 8 1
      README.md
  3. 10 23
      example/lib/main.dart
  4. 120 29
      lib/src/i18n_model.dart
  5. 1 1
      pubspec.yaml

+ 2 - 1
CHANGELOG.md

@@ -19,4 +19,5 @@
 ## [1.0.7] - fix max/min time for datetime type picker
 ## [1.0.8] - add Russian
 ## [1.0.9] - fix readme
-## [1.1.0] - fix readme
+## [1.1.0] - fix readme
+## [1.1.1] - add 3 more languages

+ 8 - 1
README.md

@@ -4,7 +4,14 @@
 
 A flutter date time picker inspired by [flutter-cupertino-date-picker](https://github.com/wuzhendev/flutter-cupertino-date-picker)
 
-you can choose date / time / date&time in English, Dutch, Chinese and Russian
+you can choose date / time / date&time in multiple languages:
+- English
+- Dutch
+- Chinese
+- Russian
+- Italian
+- French
+- Spanish
 
 and you can also custom your own picker content
 

+ 10 - 23
example/lib/main.dart

@@ -35,10 +35,8 @@ class HomePage extends StatelessWidget {
                       maxTime: DateTime(2019, 6, 7),
                       theme: DatePickerTheme(
                           backgroundColor: Colors.blue,
-                          itemStyle: TextStyle(
-                              color: Colors.white, fontWeight: FontWeight.bold),
-                          doneStyle:
-                              TextStyle(color: Colors.white, fontSize: 16)),
+                          itemStyle: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
+                          doneStyle: TextStyle(color: Colors.white, fontSize: 16)),
                       onChanged: (date) {
                     print('change $date');
                   }, onConfirm: (date) {
@@ -51,8 +49,7 @@ class HomePage extends StatelessWidget {
                 )),
             FlatButton(
                 onPressed: () {
-                  DatePicker.showTimePicker(context, showTitleActions: true,
-                      onChanged: (date) {
+                  DatePicker.showTimePicker(context, showTitleActions: true, onChanged: (date) {
                     print('change $date');
                   }, onConfirm: (date) {
                     print('confirm $date');
@@ -64,14 +61,11 @@ class HomePage extends StatelessWidget {
                 )),
             FlatButton(
                 onPressed: () {
-                  DatePicker.showDateTimePicker(context, showTitleActions: true,
-                      onChanged: (date) {
+                  DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
                     print('change $date');
                   }, onConfirm: (date) {
                     print('confirm $date');
-                  },
-                      currentTime: DateTime(2008, 12, 31, 23, 12, 34),
-                      locale: LocaleType.zh);
+                  }, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: LocaleType.zh);
                 },
                 child: Text(
                   'show date time picker (Chinese)',
@@ -79,8 +73,7 @@ class HomePage extends StatelessWidget {
                 )),
             FlatButton(
                 onPressed: () {
-                  DatePicker.showDateTimePicker(context, showTitleActions: true,
-                      onChanged: (date) {
+                  DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
                     print('change $date');
                   }, onConfirm: (date) {
                     print('confirm $date');
@@ -92,14 +85,11 @@ class HomePage extends StatelessWidget {
                 )),
             FlatButton(
                 onPressed: () {
-                  DatePicker.showDateTimePicker(context, showTitleActions: true,
-                      onChanged: (date) {
+                  DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
                     print('change $date');
                   }, onConfirm: (date) {
                     print('confirm $date');
-                  },
-                      currentTime: DateTime(2008, 12, 31, 23, 12, 34),
-                      locale: LocaleType.nl);
+                  }, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: LocaleType.nl);
                 },
                 child: Text(
                   'show date time picker (Dutch)',
@@ -107,14 +97,11 @@ class HomePage extends StatelessWidget {
                 )),
             FlatButton(
                 onPressed: () {
-                  DatePicker.showDateTimePicker(context, showTitleActions: true,
-                      onChanged: (date) {
+                  DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
                     print('change $date');
                   }, onConfirm: (date) {
                     print('confirm $date');
-                  },
-                      currentTime: DateTime(2008, 12, 31, 23, 12, 34),
-                      locale: LocaleType.ru);
+                  }, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: LocaleType.ru);
                 },
                 child: Text(
                   'show date time picker (Russian)',

+ 120 - 29
lib/src/i18n_model.dart

@@ -1,8 +1,11 @@
 enum LocaleType {
+  en,
   zh,
   nl,
-  en,
   ru,
+  it,
+  fr,
+  es,
 }
 final _i18nModel = {
   'en': {
@@ -47,34 +50,8 @@ final _i18nModel = {
     'cancel': '取消',
     'done': '确定',
     'today': '今天',
-    'monthShort': [
-      '一月',
-      '二月',
-      '三月',
-      '四月',
-      '五月',
-      '六月',
-      '七月',
-      '八月',
-      '九月',
-      '十月',
-      '十一月',
-      '十二月'
-    ],
-    'monthLong': [
-      '一月',
-      '二月',
-      '三月',
-      '四月',
-      '五月',
-      '六月',
-      '七月',
-      '八月',
-      '九月',
-      '十月',
-      '十一月',
-      '十二月'
-    ],
+    'monthShort': ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
+    'monthLong': ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
     'day': ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'],
     'am': '上午',
     'pm': '下午'
@@ -160,6 +137,114 @@ final _i18nModel = {
     'am': 'AM',
     'pm': 'PM'
   },
+  'it': {
+    'cancel': 'Annulla',
+    'done': 'Conferma',
+    'today': 'Oggi',
+    'monthShort': [
+      'Gen',
+      'Feb',
+      'Mar',
+      'Apr',
+      'Mag',
+      'Giu',
+      'Lug',
+      'Ago',
+      'Set',
+      'Ott',
+      'Nov',
+      'Dic'
+    ],
+    'monthLong': [
+      'Gennaio',
+      'Febbraio',
+      'Marzo',
+      'Aprile',
+      'Maggio',
+      'Giugno',
+      'Luglio',
+      'Agosto',
+      'Settembre',
+      'Ottobre',
+      'Novembre',
+      'Dicembre'
+    ],
+    'day': ['Lun', 'Mar', 'Mer', 'Giov', 'Ven', 'Sab', 'Dom'],
+    'am': 'AM',
+    'pm': 'PM'
+  },
+  'fr': {
+    'cancel': 'Annuler',
+    'done': 'Confirmer',
+    'today': "Aujourd'hui",
+    'monthShort': [
+      'Jan',
+      'Fév',
+      'Mar',
+      'Avr',
+      'Mai',
+      'Juin',
+      'Juil',
+      'Aoû',
+      'Sep',
+      'Oct',
+      'Nov',
+      'Déc'
+    ],
+    'monthLong': [
+      'Janvier',
+      'Février',
+      'Mars',
+      'Avril',
+      'Mai',
+      'Juin',
+      'Juillet',
+      'Août',
+      'Septembre',
+      'Octobre',
+      'November',
+      'Décembre'
+    ],
+    'day': ['Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim'],
+    'am': 'AM',
+    'pm': 'PM'
+  },
+  'es': {
+    'cancel': 'Cancelar',
+    'done': 'Confirmar',
+    'today': 'Hoy',
+    'monthShort': [
+      'Ene',
+      'Feb',
+      'Mar',
+      'Abr',
+      'May',
+      'Jun',
+      'Jul',
+      'Ago',
+      'Sep',
+      'Oct',
+      'Nov',
+      'Dic'
+    ],
+    'monthLong': [
+      'Enero',
+      'Febrero',
+      'Marzo',
+      'Abril',
+      'Mayo',
+      'Junio',
+      'Julio',
+      'Agosto',
+      'Septiembre',
+      'Octubre',
+      'Noviembre',
+      'Diciembre'
+    ],
+    'day': ['Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb', 'Dom'],
+    'am': 'AM',
+    'pm': 'PM'
+  }
 };
 //get international object
 Map<String, dynamic> i18nObjInLocale(LocaleType type) {
@@ -170,6 +255,12 @@ Map<String, dynamic> i18nObjInLocale(LocaleType type) {
       return _i18nModel['nl'];
     case LocaleType.ru:
       return _i18nModel['ru'];
+    case LocaleType.it:
+      return _i18nModel['it'];
+    case LocaleType.fr:
+      return _i18nModel['fr'];
+    case LocaleType.es:
+      return _i18nModel['es'];
     default:
       return _i18nModel['en'];
   }

+ 1 - 1
pubspec.yaml

@@ -1,6 +1,6 @@
 name: flutter_datetime_picker
 description: A date time picker for flutter, you can choose date / time / date&time in English Dutch and Chinese, and you can also custom your own picker content
-version: 1.1.0
+version: 1.1.1
 author: Realank <realank@126.com>
 homepage: https://github.com/Realank/flutter_datetime_picker