diff options
author | José Carlos Nieto <jose.carlos@menteslibres.net> | 2016-02-20 07:32:53 -0600 |
---|---|---|
committer | José Carlos Nieto <jose.carlos@menteslibres.net> | 2016-02-20 07:32:53 -0600 |
commit | 5d066dc1ea25bec034cb364f6b2fb73283bda063 (patch) | |
tree | d84ea7ec068b7998adae2bd4580db9dc78584c56 /README.md | |
parent | Code cleaning. (diff) | |
parent | Merge branch 'master' of github.com:gosexy/gettext (diff) | |
download | gotext-5d066dc1ea25bec034cb364f6b2fb73283bda063.tar.gz gotext-5d066dc1ea25bec034cb364f6b2fb73283bda063.tar.xz |
Code cleaning.
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 39 |
1 files changed, 19 insertions, 20 deletions
@@ -20,6 +20,8 @@ export CGO_CPPFLAGS=-I/usr/local/opt/gettext/include go get github.com/gosexy/gettext ``` +Installation should be straightforward on Linux. + ## Installation Use `go get` to download and install the binding: @@ -30,6 +32,9 @@ go get github.com/gosexy/gettext ## Usage +This is an example program showing the `BindTextdomain`, `Textdomain` and +`SetLocale` bindings: + ```go package main @@ -51,27 +56,27 @@ func main() { } ``` -You can use `os.Setenv` to set the `LANGUAGE` environment variable or set it -on a terminal: +Set the `LANGUAGE` env to the name of the language you want to use in your +program: ```sh export LANGUAGE="es_MX.utf8" -./gettext-program +./myapp ``` -Note that `xgettext` does not officially support Go syntax yet, however, you -can generate a valid `.pot` file by forcing `xgettest` to use the C++ -syntax: +You can use the `xgettext` command to extract strings to be translated from a +Go program: -```sh -xgettext -d example -s gettext_test.go -o example.pot -L c++ -i \ ---keyword=NGettext:1,2 --keyword=Gettext +``` +go get github.com/gosexy/gettext/go-xgettext + +xgettext -o outfile.pot --keyword=Gettext --keyword-plural=NGettext -i infile.go ``` This will generate a `example.pot` file. -After translating the `.pot` file, you must generate `.po` and `.mo` files and -remember to set the UTF-8 charset. +After actually translating the `.pot` file, you'll have to generate `.po` and +`.mo` files with `msginit` and `msgfmt`: ```sh msginit -l es_MX -o example.po -i example.pot @@ -86,21 +91,15 @@ mv example.mo examples/es_MX.utf8/LC_MESSAGES/example.mo ## Documentation -You can read `gosexy/gettext` documentation from a terminal - -```sh -go doc github.com/gosexy/gettext -``` - -Or you can [browse it](http://godoc.org/github.com/gosexy/gettext) online. +Check out the API documentation [godoc.org/github.com/gosexy/gettext)](http://godoc.org/github.com/gosexy/gettext). -The original gettext documentation could be very useful as well: +The original gettext documentation: ```sh man 3 gettext ``` -Here's another [good tutorial][2] on using gettext. +And here's a [good tutorial][2] on using gettext. [1]: http://www.gnu.org/software/gettext/ [2]: http://oriya.sarovar.org/docs/gettext_single.html |