Documentation ¶
Overview ¶
Package langs contains the language related types and function.
Index ¶
- Variables
- func DecodeConfig(m map[string]any) (map[string]LanguageConfig, error)
- func GetLocation(l *Language) *time.Location
- func GetTimeFormatter(l *Language) htime.TimeFormatter
- func GetTranslator(l *Language) locales.Translator
- func SetParams(l *Language, params maps.Params)
- type Collator
- type Language
- type LanguageConfig
- type Languages
Constants ¶
This section is empty.
Variables ¶
View Source
var DeprecationFunc = func(item, alternative string, err bool) {}
This is injected from hugolib to avoid circular dependencies.
Functions ¶
func DecodeConfig ¶ added in v0.112.0
func DecodeConfig(m map[string]any) (map[string]LanguageConfig, error)
func GetLocation ¶ added in v0.87.0
func GetTimeFormatter ¶ added in v0.97.0
func GetTimeFormatter(l *Language) htime.TimeFormatter
func GetTranslator ¶ added in v0.87.0
func GetTranslator(l *Language) locales.Translator
Types ¶
type Collator ¶ added in v0.97.0
func GetCollator1 ¶ added in v0.112.6
func GetCollator2 ¶ added in v0.112.6
func (*Collator) CompareStrings ¶ added in v0.97.0
CompareStrings compares a and b. It returns -1 if a < b, 1 if a > b and 0 if a == b. Note that the Collator is not thread safe, so you may want to acquire a lock on it before calling this method.
type Language ¶
type Language struct { // The language code, e.g. "en" or "no". // This is currently only settable as the key in the language map in the config. Lang string // Fields from the language config. LanguageConfig // contains filtered or unexported fields }
func NewLanguage ¶
func NewLanguage(lang, defaultContentLanguage, timeZone string, languageConfig LanguageConfig) (*Language, error)
NewLanguage creates a new language.
func (*Language) LanguageCode ¶ added in v0.112.4
type LanguageConfig ¶ added in v0.112.0
type LanguageConfig struct { // The language name, e.g. "English". LanguageName string // The language code, e.g. "en-US". LanguageCode string // The language title. When set, this will // override site.Title for this language. Title string // The language direction, e.g. "ltr" or "rtl". LanguageDirection string // The language weight. When set to a non-zero value, this will // be the main sort criteria for the language. Weight int // Set to true to disable this language. Disabled bool }
LanguageConfig holds the configuration for a single language. This is what is read from the config file.
Click to show internal directories.
Click to hide internal directories.