Documentation ¶
Index ¶
- Constants
- Variables
- func IsLocalizable(obj interface{}) (isLocalizable bool)
- func IsLocalizableFromContext(ctx context.Context) (localeCode string, isLocalizable bool)
- func LocalePathFromContext(m interface{}, ctx context.Context) (localePath string)
- func MustGetTranslation(r *http.Request, key string) string
- type Builder
- func (b *Builder) Activity(v *activity.Builder) (r *Builder)
- func (b *Builder) ContextValueProvider(in context.Context) context.Context
- func (b *Builder) EnsureLocale(in http.Handler) (out http.Handler)
- func (b *Builder) GetAllLocalePaths() (r []string)
- func (b *Builder) GetCookieName() string
- func (b *Builder) GetCorrectLocaleCode(r *http.Request) string
- func (b *Builder) GetCurrentLocaleCodeFromCookie(r *http.Request) (localeCode string)
- func (b *Builder) GetLocaleImg(localeCode string) string
- func (b *Builder) GetLocaleLabel(localeCode string) string
- func (b *Builder) GetLocalePath(localeCode string) string
- func (b *Builder) GetQueryName() string
- func (b *Builder) GetSupportLocaleCodes() (r []string)
- func (b *Builder) GetSupportLocaleCodesFromRequest(R *http.Request) []string
- func (b *Builder) Install(pb *presets.Builder) error
- func (b *Builder) IsTurnedOn() bool
- func (b *Builder) ModelInstall(pb *presets.Builder, m *presets.ModelBuilder) error
- func (b *Builder) RegisterLocales(localeCode, localePath, localeLabel, img string) (r *Builder)
- func (b *Builder) SupportLocalesFunc(v func(R *http.Request) []string) (r *Builder)
- type Locale
- type LocaleInterface
- type Messages
- type SelectLocale
Constants ¶
View Source
const ( WrapHandlerKey = "l10nWrapHandlerKey" MenuTopItemFunc = "l10nMenuTopItemFunc" SlugLocaleCode = "locale_code" )
View Source
const ( Localize = "l10n_LocalizeEvent" DoLocalize = "l10n_DoLocalizeEvent" FromID = "l10n_DoLocalize_FromID" FromVersion = "l10n_DoLocalize_FromVersion" FromLocale = "l10n_DoLocalize_FromLocale" LocalizeFrom = "Localize From" LocalizeTo = "Localize To" )
View Source
const ( InternationalSvg = `` /* 4392-byte string literal not displayed */ ChinaSvg = `` /* 1039-byte string literal not displayed */ JapanSvg = `` /* 473-byte string literal not displayed */ )
View Source
const I18nLocalizeKey i18n.ModuleKey = "I18nLocalizeKey"
View Source
const LocaleCode l10nContextKey = iota
Variables ¶
View Source
var IncorrectLocaleErr = errors.New("incorrect locale")
View Source
var Messages_en_US = &Messages{
Localize: "Localize",
LocalizeFrom: "From",
LocalizeTo: "To",
SuccessfullyLocalized: "Successfully Localized",
Location: "Location",
Colon: ":",
International: "International",
China: "China",
Japan: "Japan",
}
View Source
var Messages_ja_JP = &Messages{
Localize: "ローカライズ",
LocalizeFrom: "から",
LocalizeTo: "に",
SuccessfullyLocalized: "ローカライズに成功しました",
Location: "場所",
Colon: ":",
International: "国際的",
China: "中国",
Japan: "日本",
}
View Source
var Messages_zh_CN = &Messages{
Localize: "本地化",
LocalizeFrom: "从",
LocalizeTo: "到",
SuccessfullyLocalized: "本地化成功",
Location: "地区",
Colon: ":",
International: "全球",
China: "中国",
Japan: "日本",
}
Functions ¶
func IsLocalizable ¶
func IsLocalizable(obj interface{}) (isLocalizable bool)
func IsLocalizableFromContext ¶ added in v3.0.1
func LocalePathFromContext ¶ added in v3.0.1
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func (*Builder) ContextValueProvider ¶ added in v3.0.1
func (*Builder) GetAllLocalePaths ¶
func (*Builder) GetCookieName ¶
func (*Builder) GetCorrectLocaleCode ¶
func (*Builder) GetCurrentLocaleCodeFromCookie ¶
func (*Builder) GetLocaleImg ¶ added in v3.0.2
func (*Builder) GetLocaleLabel ¶
func (*Builder) GetLocalePath ¶
func (*Builder) GetQueryName ¶
func (*Builder) GetSupportLocaleCodes ¶
func (*Builder) GetSupportLocaleCodesFromRequest ¶
func (*Builder) IsTurnedOn ¶
func (*Builder) ModelInstall ¶ added in v3.0.1
func (*Builder) RegisterLocales ¶
type Locale ¶
type Locale struct {
LocaleCode string `sql:"size:20" gorm:"primaryKey;default:''"`
}
Locale embed this struct into GROM-backend models to enable localization feature for your model
func EmbedLocale ¶ added in v3.0.1
func (*Locale) EmbedLocale ¶ added in v3.0.1
GetLocale get model's locale
type LocaleInterface ¶ added in v3.0.1
type LocaleInterface interface {
EmbedLocale() *Locale
}
type SelectLocale ¶ added in v3.0.1
type SelectLocale struct { // label is a descriptive name used to display the name of a language or region to the user. // It is usually a user-friendly string, such as "English", "French", "Chinese", etc. In the user interface, // it is used to display selectable localization options. Label string // code is an identifier that represents a language or locale. // It is usually a string that represents a specific language or region code, such as "en" (English), "fr" (French), "zh" (Chinese), etc. In code, // it is used to distinguish between different localized versions. Code string }
Click to show internal directories.
Click to hide internal directories.