Documentation
¶
Index ¶
- func Init(opts ...Option)
- type LocaleOption
- type Localizer
- type Option
- func WithDefaultTemplateFuncs() Option
- func WithMsgDir(dirs ...string) Option
- func WithMsgFiles(paths ...string) Option
- func WithMsgFilesDirFs(fs fs.ReadDirFS, dirs ...string) Option
- func WithMsgFilesFs(fs fs.FS, paths ...string) Option
- func WithTemplateDelim(left, right string) Option
- func WithTemplateFunc(name string, f any) Option
- func WithTemplateFuncs(fs map[string]any) Option
- func WithUnmarshaler(ft string, unmarshalFunc i18n.UnmarshalFunc) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LocaleOption ¶
type LocaleOption func(*i18n.LocalizeConfig)
func WithParam ¶
func WithParam(param any) LocaleOption
func WithPluralCount ¶
func WithPluralCount(pluralCount any) LocaleOption
Plura的一些使用场景 英语: 复数形式:通常情况下,当数字为 1 时使用单数形式,其他情况使用复数形式。 示例: 1 apple 2 apples 0 apples
西班牙语: 复数形式:通常情况下,当数字为 1 时使用单数形式,其他情况使用复数形式。 示例: 1 manzana (苹果) 2 manzanas 0 manzanas
法语:
复数形式:通常情况下,当数字为 0 或 1 时使用单数形式,其他情况使用复数形式。 示例: 1 pomme (苹果) 2 pommes 0 pommes
德语:
复数形式:通常情况下,当数字为 1 时使用单数形式,其他情况使用复数形式。 示例: 1 Apfel (苹果) 2 Äpfel 0 Äpfel
俄语:
复数形式:通常情况下,1 对应单数形式,2-4 对应复数形式,5 及以上对应另一种复数形式。 示例: 1 яблоко (苹果) 2 яблока 5 яблок
意大利语:
复数形式:通常情况下,1 对应单数形式,其他情况使用复数形式。 示例: 1 mela (苹果) 2 mele 0 mele
葡萄牙语:
复数形式:通常情况下,当数字为 1 时使用单数形式,其他情况使用复数形式。 示例: 1 maçã (苹果) 2 maçãs 0 maçãs
阿拉伯语:
复数形式:规则较复杂,通常与数字的形式、性别和状态等有关。 示例: ١ تفاحة (苹果) ٢ تفاحة ٥ تفاحات ------------------------------------------- Plura必须为int或float类型,否则会出现panic Plura为句子中包含的数量值,i18n通过这个判断使用哪种类型的句式
type Localizer ¶
type Localizer struct {
// contains filtered or unexported fields
}
func GetLocalizer ¶
type Option ¶
type Option func(*langset)
func WithDefaultTemplateFuncs ¶
func WithDefaultTemplateFuncs() Option
import sprig(https://github.com/Masterminds/sprig) template funcs
func WithMsgDir ¶
func WithMsgFiles ¶
func WithTemplateDelim ¶
set delimiters in template
func WithTemplateFuncs ¶
add template functions eg: WithTemplateFuncs(sprig.FuncMap()) import sprig(https://github.com/Masterminds/sprig) template funcs
func WithUnmarshaler ¶
func WithUnmarshaler(ft string, unmarshalFunc i18n.UnmarshalFunc) Option
set the Unmarshaler to parse the language file for the specified file type