Skip to content
gettext in golang
Go Python
Branch: master
Clone or download
Pull request Compare This branch is 6 commits ahead of ojii:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
pluralforms
testdata Deal with missing plural forms string in mo files Nov 29, 2016
.gitignore initial commit Jul 5, 2016
.travis.yml
LICENSE initial commit Jul 5, 2016
README.md
gettext.go
gettext_test.go
go.mod
mofile.go
mofile_test.go
test_utils.go

README.md

gettext in golang

Build Status

TODO

  • parse mofiles
  • compile plural forms
  • non-utf8 mo files (possible wontfix)
  • gettext
  • ngettext
  • managing mo files / sane API

Example

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))
You can’t perform that action at this time.