https://github.com/hansmi/zyt
Date translator for Go
https://github.com/hansmi/zyt
date datetime golang i18n l10n language locale time translation
Last synced: 2 months ago
JSON representation
Date translator for Go
- Host: GitHub
- URL: https://github.com/hansmi/zyt
- Owner: hansmi
- License: bsd-3-clause
- Created: 2023-06-13T23:10:41.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-01T20:45:41.000Z (3 months ago)
- Last Synced: 2025-03-01T21:27:10.539Z (3 months ago)
- Topics: date, datetime, golang, i18n, l10n, language, locale, time, translation
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Date translator for Go
[][releases]
[](https://github.com/hansmi/zyt/actions/workflows/ci.yaml)
[](https://pkg.go.dev/github.com/hansmi/zyt)The zyt[^name-explanation] package translates month and day names from Go's
[time](https://pkg.go.dev/time) package to and from non-English languages.When parsing multiple name variants are understood. For example the month
January in German is recognized as
[`Januar`](https://de.wikipedia.org/wiki/Januar), `Jänner` and multiple
abbreviations.Languages using partitive and genitive cases for months and days are supported
(e.g. Finnish and many Slavic languages).Locales can be customized by users, either by defining from scratch or by
cloning and modifying.[^name-explanation]: _Zyt_ is Swiss German for _time_.
## Usage
To print the current time in German:
```go
fmt.Println(zyt.German.Format(time.RFC850, time.Now()))
```To parse a timestamp in Finnish:
```go
fmt.Println(zyt.Finnish.ParseInLocation("January 2006", "maaliskuu 2001", time.UTC))
```To select the best-fitting locale:
```go
l, _ := zyt.Best(language.BritishEnglish)
l.Format(time.RFC850, time.Now())
```## Supported locales
* English
* German
* Austrian German
* FinnishContributions to add more are very welcome.
## Alternatives
* [github.com/goodsign/monday](https://pkg.go.dev/github.com/goodsign/monday),
an older package only supporting one variant per name.[releases]: https://github.com/hansmi/zyt/releases/latest