Documentation
¶
Overview ¶
Package locale provides internationalization (i18n) support for the l-ui web panel, including translation loading, localization, and middleware for web and bot interfaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( LocalizerWeb *i18n.Localizer LocalizerBot *i18n.Localizer )
Functions ¶
func I18n ¶
I18n retrieves a localized message for the given key and type. It supports both bot and web contexts, with optional template parameters. Returns the localized message or an empty string if localization fails.
func InitLocalizer ¶
func InitLocalizer(i18nFS embed.FS, settingService SettingService) error
InitLocalizer initializes the internationalization system with embedded translation files.
func LocalizerMiddleware ¶
func LocalizerMiddleware() gin.HandlerFunc
LocalizerMiddleware returns a Gin middleware that sets up localization for web requests. It determines the user's language from cookies or Accept-Language header, creates a localizer instance, and stores it in the Gin context for use in handlers. Also provides the I18n function in the context for template rendering.
Types ¶
type I18nType ¶
type I18nType string
I18nType represents the type of interface for internationalization.
type SettingService ¶
SettingService interface defines methods for accessing locale settings.