Przeglądaj źródła

add more languages

Liu Yanbo 6 lat temu
rodzic
commit
d19dc1f1f5
5 zmienionych plików z 75 dodań i 23 usunięć
  1. 2 1
      CHANGELOG.md
  2. 2 0
      README.md
  3. 23 10
      example/lib/main.dart
  4. 47 11
      lib/src/i18n_model.dart
  5. 1 1
      pubspec.yaml

+ 2 - 1
CHANGELOG.md

@@ -22,4 +22,5 @@
 ## [1.1.0] - fix readme
 ## [1.1.1] - add 3 more languages
 ## [1.1.2] - add Portuguese
-## [1.1.3] - update date picker format
+## [1.1.3] - update date picker format
+## [1.1.4] - add 2 more languages

+ 2 - 0
README.md

@@ -14,6 +14,8 @@ you can choose date / time / date&time in multiple languages:
 - French(fr)
 - Spanish(es)
 - Portuguese(pt)
+- Korean(ko)
+- Arabic(ar)
 
 and you can also custom your own picker content
 

+ 23 - 10
example/lib/main.dart

@@ -35,8 +35,10 @@ 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) {
@@ -49,7 +51,8 @@ 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');
@@ -61,11 +64,14 @@ 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)',
@@ -73,7 +79,8 @@ 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');
@@ -85,11 +92,14 @@ 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)',
@@ -97,11 +107,14 @@ 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)',

+ 47 - 11
lib/src/i18n_model.dart

@@ -1,14 +1,4 @@
-enum LocaleType {
-  en,
-  zh,
-  nl,
-  ru,
-  it,
-  fr,
-  es,
-  pt,
-  ko,
-}
+enum LocaleType { en, zh, nl, ru, it, fr, es, pt, ko, ar }
 final _i18nModel = {
   'en': {
     //default
@@ -345,6 +335,50 @@ final _i18nModel = {
     'am': '오전',
     'pm': '오후'
   },
+  'ar': {
+    'cancel': 'إنهاء',
+    'done': 'تأكيد',
+    'today': 'اليوم',
+    'monthShort': [
+      'يناير',
+      'فبراير',
+      'مارس',
+      'إبريل',
+      'مايو',
+      'يونيو',
+      'يوليو',
+      'أغسطس',
+      'سبتمبر',
+      'أكتوبر',
+      'نوفمبر',
+      'ديسمبر'
+    ],
+    'monthLong': [
+      'يناير',
+      'فبراير',
+      'مارس',
+      'إبريل',
+      'مايو',
+      'يونيو',
+      'يوليو',
+      'أغسطس',
+      'سبتمبر',
+      'أكتوبر',
+      'نوفمبر',
+      'ديسمبر'
+    ],
+    'day': [
+      'الإثنين',
+      'الثلاثاء',
+      'الأربعاء',
+      'الخميس',
+      'الجمعه',
+      'السبت',
+      'الاحد'
+    ],
+    'am': 'ص',
+    'pm': 'م'
+  },
 };
 //get international object
 Map<String, dynamic> i18nObjInLocale(LocaleType type) {
@@ -365,6 +399,8 @@ Map<String, dynamic> i18nObjInLocale(LocaleType type) {
       return _i18nModel['pt'];
     case LocaleType.ko:
       return _i18nModel['ko'];
+    case LocaleType.ar:
+      return _i18nModel['ar'];
     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.3
+version: 1.1.4
 author: Realank <realank@126.com>
 homepage: https://github.com/Realank/flutter_datetime_picker