Documentation ¶
Overview ¶
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)
Language + Region => en-us | en-US
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 ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type I18n ¶
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 NewWithVFS ¶
NewWithVFS method creates aah i18n message store with given Virtual FileSystem.
func (*I18n) Load ¶
Load processes the given message file or directory and adds to the message store
func (*I18n) Lookup ¶
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)