Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ojii/gettext.go
gettext in golang
https://github.com/ojii/gettext.go
gettext golang i18n
Last synced: 8 days ago
JSON representation
gettext in golang
- Host: GitHub
- URL: https://github.com/ojii/gettext.go
- Owner: ojii
- License: other
- Created: 2016-06-27T09:14:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-11-05T10:07:17.000Z (about 4 years ago)
- Last Synced: 2024-06-19T10:08:21.342Z (5 months ago)
- Topics: gettext, golang, i18n
- Language: Go
- Size: 23.4 KB
- Stars: 8
- Watchers: 3
- Forks: 13
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gettext in golang
[![Build Status](https://travis-ci.org/ojii/gettext.go.svg?branch=master)](https://travis-ci.org/ojii/gettext.go)
## TODO
- [x] parse mofiles
- [x] compile plural forms
- [ ] non-utf8 mo files (possible wontfix)
- [x] gettext
- [x] ngettext
- [x] managing mo files / sane API## Example
```go
import gettext
translations := gettext.NewTranslations("path/to/translations/", "messages", gettext.DefaultResolver)
locale := translations.Locale("en")
fmt.Println(locale.Gettext("hello from gettext"))
one := 1
two := 2fmt.Println(fmt.Sprintf(locale.NGettext("%d thing", "%d things", uint32(one)), one))
fmt.Println(fmt.Sprintf(locale.NGettext("%d thing", "%d things", uint32(two)), two))
```