Improved docs
This commit is contained in:
54
README.md
54
README.md
@@ -9,13 +9,15 @@ GNU gettext utilities for Go.
|
||||
|
||||
#Features
|
||||
|
||||
- Implements GNU gettext support in native Go.
|
||||
- It works with UTF-8 encoding as it's the default for Go language.
|
||||
- Supports pluralization rules.
|
||||
- Ready to use inside Go templates.
|
||||
- Safe for concurrent use accross multiple goroutines.
|
||||
- Implements GNU gettext support in native Go.
|
||||
- Safe for concurrent use accross multiple goroutines.
|
||||
- It works with UTF-8 encoding as it's the default for Go language.
|
||||
- Unit tests available
|
||||
- Language codes are automatically simplified from the form "en_UK" to "en" if the formed isn't available.
|
||||
- Unit tests available
|
||||
- Ready to use inside Go templates.
|
||||
- Support for pluralization rules.
|
||||
- Support for variables inside translation strings using the Go's [fmt package syntax](https://golang.org/pkg/fmt/)
|
||||
|
||||
|
||||
|
||||
# Installation
|
||||
@@ -39,6 +41,46 @@ go get github.com/leonelquinteros/gotext
|
||||
Refer to the Godoc package documentation at (https://godoc.org/github.com/leonelquinteros/gotext)
|
||||
|
||||
|
||||
# Locales directories structure
|
||||
|
||||
The package will asume a directories structure starting with a base path that will be provided to the package configuration
|
||||
or to object constructors depending on the use, but either will use the same convention to lookup inside the base path.
|
||||
|
||||
Inside the base directory where will be the language directories named using the language and country 2-letter codes (en_US, es_AR, ...).
|
||||
All package functions can lookup after the simplified version for each language in case the full code isn't present but the more general language code exists.
|
||||
So if the language set is "en_UK", but there is no directory named after that code and there is a directory named "en",
|
||||
all package functions will be able to resolve this generalization and provide translations for the more general library.
|
||||
|
||||
The language codes are assumed to be [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) codes (2-letter codes).
|
||||
That said, most functions will work with any coding standard as long the directory name matches the language code set on the configuration.
|
||||
|
||||
A normal library directory structure may look like:
|
||||
|
||||
```
|
||||
/path/to/locales
|
||||
/path/to/locales/en_US
|
||||
/path/to/locales/en_US/default.po
|
||||
/path/to/locales/en_US/extras.po
|
||||
/path/to/locales/en_UK
|
||||
/path/to/locales/en_UK/default.po
|
||||
/path/to/locales/en_UK/extras.po
|
||||
/path/to/locales/en_AU
|
||||
/path/to/locales/en_AU/default.po
|
||||
/path/to/locales/en_AU/extras.po
|
||||
/path/to/locales/es
|
||||
/path/to/locales/es/default.po
|
||||
/path/to/locales/es/extras.po
|
||||
/path/to/locales/es_ES
|
||||
/path/to/locales/es_ES/default.po
|
||||
/path/to/locales/es_ES/extras.po
|
||||
/path/to/locales/fr
|
||||
/path/to/locales/fr/default.po
|
||||
/path/to/locales/fr/extras.po
|
||||
```
|
||||
|
||||
And so on...
|
||||
|
||||
|
||||
|
||||
# About translation function names
|
||||
|
||||
|
||||
Reference in New Issue
Block a user