localization

package
v0.0.0-...-5dd2f1f Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalizer

func GetLocalizer(c *gin.Context) *i18n.Localizer

GetLocalizer retrieves the localizer from Gin's context.

func InitLocalization

func InitLocalization(config config.LocalizationConfig)

func LoadLocaleFiles

func LoadLocaleFiles(path string) error

func LocalizationMiddleware

func LocalizationMiddleware() gin.HandlerFunc

LocalizationMiddleware detects the user's language and initializes a localizer.

func LocalizeDate

func LocalizeDate(c *gin.Context, year int, month int, day int) string

LocalizeDate formats a date according to the language in the localizer.

func LocalizePlural

func LocalizePlural(c *gin.Context, messageID string, count int) string

LocalizePlural is a helper function that localizes a message ID with pluralization

func LocalizePrefixStrings

func LocalizePrefixStrings(c *gin.Context, partialID string) map[string]string

LocalizePrefixStrings Modify the function to use SearchPrefix to find all keys that start with the given prefix, and then localize those strings.

func LocalizeStrings

func LocalizeStrings(localizer *i18n.Localizer, messageIDs []string) map[string]string

LocalizeStrings localizes a slice of message IDs and returns a map.

Types

type LocalizationData

type LocalizationData map[string]SectionData

LocalizationData holds all sections with their respective translations

type Message

type Message struct {
	ID    string `json:"id"`
	Other string `json:"other"`
}

type SectionData

type SectionData map[string]string

SectionData represents the data of a specific section in your JSON files

type Trie

type Trie struct {
	// contains filtered or unexported fields
}

type TrieNode

type TrieNode struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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