Przeglądaj źródła

Update README + Add en BC test cases

joeybloggs 9 lat temu
rodzic
commit
0a0348423d
2 zmienionych plików z 40 dodań i 1 usunięć
  1. 12 1
      README.md
  2. 28 0
      calendar_test.go

+ 12 - 1
README.md

@@ -1,6 +1,6 @@
 ## universal-translator
 ## universal-translator
 <img align="right" src="https://raw.githubusercontent.com/go-playground/universal-translator/master/logo.png">
 <img align="right" src="https://raw.githubusercontent.com/go-playground/universal-translator/master/logo.png">
-![Project status](https://img.shields.io/badge/version-0.8.1-green.svg)
+![Project status](https://img.shields.io/badge/version-0.9-green.svg)
 [![Build Status](https://semaphoreci.com/api/v1/joeybloggs/universal-translator/branches/master/badge.svg)](https://semaphoreci.com/joeybloggs/universal-translator)
 [![Build Status](https://semaphoreci.com/api/v1/joeybloggs/universal-translator/branches/master/badge.svg)](https://semaphoreci.com/joeybloggs/universal-translator)
 [![Coverage Status](https://coveralls.io/repos/github/go-playground/universal-translator/badge.svg?branch=master)](https://coveralls.io/github/go-playground/universal-translator?branch=master)
 [![Coverage Status](https://coveralls.io/repos/github/go-playground/universal-translator/badge.svg?branch=master)](https://coveralls.io/github/go-playground/universal-translator?branch=master)
 [![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/universal-translator)](https://goreportcard.com/report/github.com/go-playground/universal-translator)
 [![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/universal-translator)](https://goreportcard.com/report/github.com/go-playground/universal-translator)
@@ -25,6 +25,7 @@ Features
 - [x] Date, Time & DateTime formatting
 - [x] Date, Time & DateTime formatting
 - [x] Number, Whole Number formatting
 - [x] Number, Whole Number formatting
 - [x] Currency both standard & accounting, formatting i.e. -$1,234.50 vs ($1,234.50)
 - [x] Currency both standard & accounting, formatting i.e. -$1,234.50 vs ($1,234.50)
+- [x] Handles BC and AD Dates. i.e. January 2, 300 BC
 - [ ] Support loading translations from files
 - [ ] Support loading translations from files
 - [ ] Exporting translations to file, mainly for getting them professionally translated
 - [ ] Exporting translations to file, mainly for getting them professionally translated
 - [ ] Code Generation for translation files -> Go code.. i.e. after it has been professionally translated
 - [ ] Code Generation for translation files -> Go code.. i.e. after it has been professionally translated
@@ -156,6 +157,16 @@ func main() {
 }
 }
 ```
 ```
 
 
+Help With Tests
+---------------
+To anyone interesting in helping or contributing, I sure could use some help creating tests for each language.
+Please see issue [here](https://github.com/go-playground/universal-translator/issues/1) for details.
+
+Thanks to some help the, following languages have tests:
+
+- [x] en - English US
+- [x] th - Thai thanks to @prideloki
+
 Special Thanks
 Special Thanks
 --------------
 --------------
 Special thanks to the following libraries that not only inspired, but that I borrowed a bunch of code from to create this.. ultimately there were many changes made and more to come, but without them would have taken forever to just get started.
 Special thanks to the following libraries that not only inspired, but that I borrowed a bunch of code from to create this.. ultimately there were many changes made and more to come, but without them would have taken forever to just get started.

+ 28 - 0
calendar_test.go

@@ -39,16 +39,30 @@ func TestDateTimeEn(t *testing.T) {
 	Equal(t, err, nil)
 	Equal(t, err, nil)
 	Equal(t, dt, "Monday, January 2, 2006")
 	Equal(t, dt, "Monday, January 2, 2006")
 
 
+	dt, err = en.FmtDateFullSafe(bc300DateTime)
+	Equal(t, err, nil)
+	Equal(t, dt, "Saturday, January 2, 300 Before Christ")
+
 	dt = en.FmtDateFull(datetime)
 	dt = en.FmtDateFull(datetime)
 	Equal(t, dt, "Monday, January 2, 2006")
 	Equal(t, dt, "Monday, January 2, 2006")
 
 
+	dt = en.FmtDateFull(bc300DateTime)
+	Equal(t, dt, "Saturday, January 2, 300 Before Christ")
+
 	dt, err = en.FmtDateLongSafe(datetime)
 	dt, err = en.FmtDateLongSafe(datetime)
 	Equal(t, err, nil)
 	Equal(t, err, nil)
 	Equal(t, dt, "January 2, 2006")
 	Equal(t, dt, "January 2, 2006")
 
 
+	dt, err = en.FmtDateLongSafe(bc300DateTime)
+	Equal(t, err, nil)
+	Equal(t, dt, "January 2, 300 BC")
+
 	dt = en.FmtDateLong(datetime)
 	dt = en.FmtDateLong(datetime)
 	Equal(t, dt, "January 2, 2006")
 	Equal(t, dt, "January 2, 2006")
 
 
+	dt = en.FmtDateLong(bc300DateTime)
+	Equal(t, dt, "January 2, 300 BC")
+
 	dt, err = en.FmtDateMediumSafe(datetime)
 	dt, err = en.FmtDateMediumSafe(datetime)
 	Equal(t, err, nil)
 	Equal(t, err, nil)
 	Equal(t, dt, "Jan 2, 2006")
 	Equal(t, dt, "Jan 2, 2006")
@@ -95,16 +109,30 @@ func TestDateTimeEn(t *testing.T) {
 	Equal(t, err, nil)
 	Equal(t, err, nil)
 	Equal(t, dt, "Monday, January 2, 2006 at 3:04:05 PM")
 	Equal(t, dt, "Monday, January 2, 2006 at 3:04:05 PM")
 
 
+	dt, err = en.FmtDateTimeFullSafe(bc300DateTime)
+	Equal(t, err, nil)
+	Equal(t, dt, "Saturday, January 2, 300 Before Christ at 3:04:05 AM")
+
 	dt = en.FmtDateTimeFull(datetime)
 	dt = en.FmtDateTimeFull(datetime)
 	Equal(t, dt, "Monday, January 2, 2006 at 3:04:05 PM")
 	Equal(t, dt, "Monday, January 2, 2006 at 3:04:05 PM")
 
 
+	dt = en.FmtDateTimeFull(bc300DateTime)
+	Equal(t, dt, "Saturday, January 2, 300 Before Christ at 3:04:05 AM")
+
 	dt, err = en.FmtDateTimeLongSafe(datetime)
 	dt, err = en.FmtDateTimeLongSafe(datetime)
 	Equal(t, err, nil)
 	Equal(t, err, nil)
 	Equal(t, dt, "January 2, 2006 at 3:04:05 PM")
 	Equal(t, dt, "January 2, 2006 at 3:04:05 PM")
 
 
+	dt, err = en.FmtDateTimeLongSafe(bc300DateTime)
+	Equal(t, err, nil)
+	Equal(t, dt, "January 2, 300 BC at 3:04:05 AM")
+
 	dt = en.FmtDateTimeLong(datetime)
 	dt = en.FmtDateTimeLong(datetime)
 	Equal(t, dt, "January 2, 2006 at 3:04:05 PM")
 	Equal(t, dt, "January 2, 2006 at 3:04:05 PM")
 
 
+	dt = en.FmtDateTimeLong(bc300DateTime)
+	Equal(t, dt, "January 2, 300 BC at 3:04:05 AM")
+
 	dt, err = en.FmtDateTimeMediumSafe(datetime)
 	dt, err = en.FmtDateTimeMediumSafe(datetime)
 	Equal(t, err, nil)
 	Equal(t, err, nil)
 	Equal(t, dt, "Jan 2, 2006, 3:04:05 PM")
 	Equal(t, dt, "Jan 2, 2006, 3:04:05 PM")