Documentation
¶
Overview ¶
Package localization provides internationalization (i18n) support for Omnom.
This package handles translation of user interface strings into multiple languages using the go-i18n library. Translation files are JSON-based and embedded in the application at build time.
Supported features:
- Multiple language support with automatic fallback to English
- Parameterized message templates
- Language detection from Accept-Language headers
- Embedded translation files
Translation files are stored in the locales/ directory with names like en.json, es.json, etc. Each file contains message IDs and their translated strings.
The Localizer type provides thread-safe translation lookups for a specific language preference. The global SupportedLanguages slice contains metadata about all available translations.
Example usage:
// Create a localizer for a user's preferred languages
loc := localization.NewLocalizer("es", "en")
// Translate a simple message
text := loc.Msg("welcome_message")
// Translate with parameters
text := loc.Msgf("greeting", "name", userName, "count", itemCount)
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SupportedLanguages []*LangInfo
SupportedLanguages contains all available language translations.
Functions ¶
This section is empty.
Types ¶
type Localizer ¶
type Localizer struct {
// contains filtered or unexported fields
}
Localizer provides translation functionality.
func NewLocalizer ¶
NewLocalizer creates a new localizer for the specified languages.