Documentation
¶
Overview ¶
Package i18n 提供 vhtml CLI 的国际化管理子命令(scan/add)。
Index ¶
- func GetConfig() *runtimeConfig
- func LoadTranslations(outputPath string) (map[string]map[string]interface{}, error)
- func Register(parent *flags.Flags, c *Config, ui *string)
- func SaveTranslations(outputPath string, translations map[string]map[string]interface{}, ...) error
- type Config
- type FormatConfig
- type ScanConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadTranslations ¶
LoadTranslations 加载翻译文件
func Register ¶
Register 把 scan/add 子命令注册到 parent(`vhtml i18n`)下。 ui 为全局 -ui 配置指针:子命令经 flags 继承机制直接复用,无需重复注册。
func SaveTranslations ¶
func SaveTranslations(outputPath string, translations map[string]map[string]interface{}, format FormatConfig, defaultLanguage string) error
SaveTranslations 保存翻译文件
Types ¶
type Config ¶
type Config struct {
Languages []string `json:"languages" desc:"支持的语言列表,逗号分隔"`
DefaultLanguage string `json:"defaultLanguage" desc:"默认语言,作为翻译的基准语言"`
Output string `json:"output" desc:"输出文件路径,翻译文件的保存位置(默认 {ui}/langs.json)"`
Include []string `json:"include" desc:"包含的文件模式,支持 glob 语法"`
Exclude []string `json:"exclude" desc:"排除的文件模式,支持 glob 语法"`
Pattern string `json:"pattern" desc:"匹配翻译 key 的正则表达式"`
Indent int `json:"indent" desc:"JSON 缩进空格数"`
SortKeys bool `json:"sortKeys" desc:"是否对 key 进行排序"`
}
Config i18n 配置,对应 vhtml.config.json 的 i18n 段。 字段经 flags.AutoRegister 注册为命令行参数(env 为字段名大写)。 扫描入口不复用独立配置:直接使用全局 -ui(见 Register 注入)。
type FormatConfig ¶
FormatConfig 格式化配置
type ScanConfig ¶
ScanConfig 扫描配置
Click to show internal directories.
Click to hide internal directories.