i18n.v0: aahframework.org/i18n.v0 Index | Files

package i18n

import "aahframework.org/i18n.v0"

Package i18n is internationalization and localization support for aah framework. Messages config format is `forge` config syntax (go-aah/config) which is similar to HOCON syntax aka typesafe config.

Message filename format is `message.<Language-ID>`. Language ID is combination of `Language + Region` or `Language` value. aah framework implements Language code is as per two-letter `ISO 639-1` standard and Region code is as per two-letter `ISO 3166-1` standard.

Supported message file extension formats are (incasesensitive)

1) Language + Region => en-us | en-US
2) Language          => en

For Example:
	message.en-US or message.en-us
	message.en-GB or message.en-gb
	message.en-CA or message.en-ca
	message.en
	message.es
	message.zh
	message.nl
	etc.

Note: Sub directories is supported, so you can organize message files.

Index

Package Files

i18n.go version.go

Constants

const Version = "0.4.0"

Version no. of aah framework i18n library

type I18n Uses

type I18n struct {
    Store         map[string]*config.Config
    DefaultLocale string
    // contains filtered or unexported fields
}

I18n holds the message store and related information for internationalization and localization.

func New Uses

func New() *I18n

New method creates aah i18n message store

func NewWithVFS Uses

func NewWithVFS(fs *vfs.VFS) *I18n

NewWithVFS method creates aah i18n message store with given Virtual FileSystem.

func (*I18n) Load Uses

func (s *I18n) Load(paths ...string) error

Load processes the given message file or directory and adds to the message store

func (*I18n) Locales Uses

func (s *I18n) Locales() []string

Locales returns all the loaded locales from message store

func (*I18n) Lookup Uses

func (s *I18n) Lookup(locale *ahttp.Locale, key string, args ...interface{}) string

Lookup returns value by given key, locale and it supports formatting a message before its return. If given message key or store doesn't exists for given locale; Lookup method returns empty string.

Lookup(locale, "i.love.aah.framework", "yes")

The sequence and fallback order of message fetch from store is -

* language and region-id (e.g.: en-US)
* language (e.g.: en)

Package i18n imports 10 packages (graph) and is imported by 2 packages. Updated 2018-06-30. Refresh now. Tools for package owners.