Documentation
¶
Overview ¶
The root of the ginta i18n library. Ginta is an i18n solution that provides both simple (name=value) lookups, context-dependant translations and support for formatted output.
Ginta is designed to be easy to use and extend. Easy to use insofar as that the user needs not worry about internals such as resource loading, synchronization and lifetime. Easy to extend insofar as that it should be easy to "plug in" new ways to acquire resources or formats.
Ginta has two modes of query for a resource. A Resource can be queried, or it can be resolved. When a resource is queried, a direct lookup of the resource name is performed. If no resource with the specified name is known, an error is returned. In contrast, if a resource is resolved, its name is interpreted as a "hierarchical key" (See package common). Such a hierarchical key defines one or more super-keys. If a resource is not found under its hierarchical key, the system automatically walks through the super-keys until either a matching resource is located, or resolution fails even on the "root key", in which case an error is returned.
This package contains the basic primitive functions of ginta. These functions are used to query the translation database for resource entries, either individually or in bulk.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(p LanguageProvider)
Adds a language provider to the system. Often there will be a single provider, but there may be more. In case of multiple providers defining the same language, their definitions will be merged (that is, their resource sets combined). In this case, providers registered later will overwrite these defined earlier.
Types ¶
type Enumerator ¶
type Enumerator interface {
/* Returns all languages available on this enumerator. The returned channel must be closed after the last language has been send */
Enumerate() <-chan types.Language
}
An Enumerator is any type that can enumerate one or more languages for which resources can be loaded. Result channel must be filled with all available languages, then closed. An empty Enumerator should therefore return a closed channel.
type LanguageProvider ¶
type LanguageProvider interface {
// enumeration functionality
Enumerator
// list functionality
Lister
}
The full service provider interface. Implementions are able to provide a number of lanugages (and their contents). See the package providers for some samples.
type Lister ¶
type Lister interface {
/* Returns all resources for the language code available on this source. The returned channel must be closed after the last resource has been send */
List(code string) <-chan types.Resource
}
A Lister is any type that can list the available resources (in some backing storage) for a given language code. After all available resources have been transmitted, the returned channel must be closed.
type Locale ¶
type Locale string
Locale defines methods to access resources for a language
The default locale of the application - may be changed by the application.
func (Locale) GetResource ¶
Returns a resource by simple name matching
func (Locale) GetResourceBundle ¶
Returns a "resource bundle". This bundle is contains all resource whose hierarchical key has exactly the specified prefix - but no resources with shorter or longer prefix paths.
func (Locale) ResolveResource ¶
func (l Locale) ResolveResource(k types.HierarchicalKey) (string, error)
Resolves a resource by its hierarchical key.
Directories
¶
| Path | Synopsis |
|---|---|
|
Defines the basic types of ginta, with their methods.
|
Defines the basic types of ginta, with their methods. |
|
Provides function for messages containing variable, formatted values.
|
Provides function for messages containing variable, formatted values. |
|
nr
Detailed formatter for integers.
|
Detailed formatter for integers. |
|
plural
The plural package substitutes numeric values for "plural words".
|
The plural package substitutes numeric values for "plural words". |
|
quoted
allows output of quoted-literal (%#v) values.
|
allows output of quoted-literal (%#v) values. |
|
time
Allows formatted output of time values.
|
Allows formatted output of time values. |
|
Internal workhorse of ginta.
|
Internal workhorse of ginta. |
|
providers
|
|
|
fs
A simple, file system based provider that uses multisrc conventions to load its resources.
|
A simple, file system based provider that uses multisrc conventions to load its resources. |
|
multisrc
Parser for "resource-file" like inputs.
|
Parser for "resource-file" like inputs. |
|
simple
Simple static resource provider.
|
Simple static resource provider. |
|
The setup package makes it easy and convenient to bootstrap the ginta library
|
The setup package makes it easy and convenient to bootstrap the ginta library |