langs

package
v0.111.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 15 Imported by: 89

Documentation

Overview

Package langs contains the language related types and function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocation added in v0.87.0

func GetLocation(l *Language) *time.Location

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

type Collator struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func GetCollator added in v0.97.0

func GetCollator(l *Language) *Collator

func (*Collator) CompareStrings added in v0.97.0

func (c *Collator) CompareStrings(a, b string) int

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 aquire a lock on it before calling this method.

type Language

type Language struct {
	Lang              string
	LanguageName      string
	LanguageDirection string
	Title             string
	Weight            int

	// For internal use.
	Disabled bool

	// If set per language, this tells Hugo that all content files without any
	// language indicator (e.g. my-page.en.md) is in this language.
	// This is usually a path relative to the working dir, but it can be an
	// absolute directory reference. It is what we get.
	// For internal use.
	ContentDir string

	// Global config.
	// For internal use.
	Cfg config.Provider

	// Language specific config.
	// For internal use.
	LocalCfg config.Provider

	// Composite config.
	// For internal use.
	config.Provider
	// contains filtered or unexported fields
}

Language manages specific-language configuration.

func NewDefaultLanguage

func NewDefaultLanguage(cfg config.Provider) *Language

NewDefaultLanguage creates the default language for a config.Provider. If not otherwise specified the default is "en".

func NewLanguage

func NewLanguage(lang string, cfg config.Provider) *Language

NewLanguage creates a new language.

func (*Language) GetLocal

func (l *Language) GetLocal(key string) any

GetLocal gets a configuration value set on language level. It will not fall back to any global value. It will return nil if a value with the given key cannot be found. For internal use.

func (*Language) IsSet

func (l *Language) IsSet(key string) bool

IsSet checks whether the key is set in the language or the related config store. For internal use.

func (*Language) Merge added in v0.84.0

func (l *Language) Merge(key string, value any)

Merge is currently not supported for Language. For internal use.

func (*Language) Params

func (l *Language) Params() maps.Params

Params returns language-specific params merged with the global params.

func (*Language) Set

func (l *Language) Set(k string, v any)

For internal use.

func (*Language) SetParam

func (l *Language) SetParam(k string, v any)

SetParam sets a param with the given key and value. SetParam is case-insensitive. For internal use.

func (*Language) String

func (l *Language) String() string

For internal use.

type Languages

type Languages []*Language

Languages is a sortable list of languages.

func NewLanguages

func NewLanguages(l ...*Language) Languages

NewLanguages creates a sorted list of languages. NOTE: function is currently unused.

func (Languages) AsOrdinalSet added in v0.56.0

func (l Languages) AsOrdinalSet() map[string]int

func (Languages) AsSet added in v0.56.0

func (l Languages) AsSet() map[string]bool

func (Languages) IsMultihost

func (l Languages) IsMultihost() bool

IsMultihost returns whether there are more than one language and at least one of the languages has baseURL specificed on the language level.

func (Languages) Len

func (l Languages) Len() int

func (Languages) Less

func (l Languages) Less(i, j int) bool

func (Languages) Swap

func (l Languages) Swap(i, j int)

type LanguagesConfig added in v0.56.0

type LanguagesConfig struct {
	Languages                      Languages
	Multihost                      bool
	DefaultContentLanguageInSubdir bool
}

func LoadLanguageSettings added in v0.56.0

func LoadLanguageSettings(cfg config.Provider, oldLangs Languages) (c LanguagesConfig, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL