Documentation ¶
Index ¶
- type Language
- func (l Language) BaseISO639Language() (language.Language, error)
- func (l Language) MarshalJSON() ([]byte, error)
- func (l Language) Raw() stdLanguage.Tag
- func (l Language) String() string
- func (l *Language) UnmarshalJSON(data []byte) (err error)
- func (l Language) Validate() (err error)
- func (l *Language) Value() (value driver.Value, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Language ¶
type Language struct {
// contains filtered or unexported fields
}
Language represents a BCP49 language entity. It includes the base ISO639 language, the original BCP47 code string, and the corresponding language.Tag from the golang.org/x/text/language package.
func ByStrErr ¶
ByStrErr creates a new Language by parsing a BCP47 code string. It returns an error if the BCP47 code is invalid or if the base ISO639 language cannot be parsed.
func (Language) BaseISO639Language ¶
BaseISO639Language returns the base ISO639 language of the BCP47 code. The returned language.Language represents the most significant part of the language identification used in the BCP47 code. For example, for the BCP47 code "en-US", the base ISO639 language would be "en".
This method will return an error if the ISO639 language cannot be determined from the BCP47 code.
func (Language) MarshalJSON ¶ added in v2.0.13
MarshalJSON implements the json.Marshaler interface. It marshals the Language into its BCP47 string representation.
func (Language) Raw ¶
func (l Language) Raw() stdLanguage.Tag
Raw returns the parsed BCP47 code as a language.Tag.
func (*Language) UnmarshalJSON ¶
UnmarshalJSON unmarshals a JSON-encoded BCP47 code into a Language.