Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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 := 2

fmt.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))
```