i18n

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

多语言文件格式说明

多语文件为一个UTF8编码的JSON格式文本。

{
	"!language": {                    // 语言信息节点,必填
	    "Id": 2052,                   // 语言ID,必填
		"Name": "zh-CN",              // 语言名称,必填
		"Description": "简体中文",     // 语言描述名,必填
		"Author": "ying32",           // 作者名,选填
		"AuthorEmail": "1444386932@qq.com" // 作者Email,选填
	},
	"!libresources": {                // libvcl或者liblcl中的字符资源,固定项目
		"SOpenFileTitle": "打开",
		"SOKButton": "确定",
		"SCancelButton": "取消",
		"SYesButton": "是(&Y)",
		"SNoButton": "否(&N)",
		"SHelpButton": "帮助(&H)",
		"SCloseButton": "帮助(&C)",
		"SIgnoreButton": "忽略(&I)",
		"SRetryButton": "重试(&R)",
		"SAbortButton": "终止",
		"SAllButton": "全部(&A)",
		"SMsgDlgWarning": "警告",
		"SMsgDlgError": "错误",
		"SMsgDlgInformation": "信息",
		"SMsgDlgConfirm": "询问",
		"SMsgDlgYes": "是(&Y)",
		"SMsgDlgNo": "否(&N)",
		"SMsgDlgOK": "确定",
		"SMsgDlgCancel": "取消",
		"SMsgDlgHelp": "帮助(&H)",
		"SMsgDlgHelpNone": "没有有效的帮助",
		"SMsgDlgHelpHelp": "帮助",
		"SMsgDlgAbort": "终止(&A)",
		"SMsgDlgRetry": "重试(&R)",
		"SMsgDlgIgnore": "忽略(&I)",
		"SMsgDlgAll": "全部(&A)",
		"SMsgDlgNoToAll": "全否(&o)",
		"SMsgDlgYesToAll": "全是(&A)",
		"SMsgDlgClose": "关闭(&C)"
	},

	"!resources": { // 所有应用程序共享资源节点,比如app1.exe , app2.exe他们之前有相同的资源就放这里
	},

	"multilanguage": { // app节点起始,名称一般为当前应用程序名称,如果改为其他,需要在程序中指定节点
		"!resources": { // 当前app中的共享资源
			"testMessage": "这是一个测试消息!"
		},

		"Form1": { // 窗口名称,必须一致,之后在OnFormCreate中首行添加multilang.InitComponentLang(f)代码初始注册
		   "Caption": "多语言测试",  // 一级标题属性,名称都是根据控件名+属性名来操作的,这个就是直接设置窗口的了,二级类的比如 Font.Size: 12等等
		   "Button1.Caption": "按钮", // 子控件
		   "MenuItem1.Caption": "文件(&F)",
           "MenuItem2.Caption": "菜单项目2",
           "MenuItem3.Caption": "菜单项目3",
           "MenuItem4.Caption": "菜单项目4",
           "MenuItem5.Caption": "菜单项目5",
           "MenuItem6.Caption": "菜单项目6",
           "MenuItem7.Caption": "菜单项目7",
           "MenuItem8.Caption": "菜单项目8",
           "MenuItem9.Caption": "菜单项目9",
           "MenuItem10.Caption": "菜单项目10"
		}
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// LocalLangs
	//
	// 本地已经添加了的语言列表。
	//
	// List of languages that have been added locally.
	LocalLangs = make(map[int]TLangItem, 0)

	// AppNodeName
	//
	// 默认应用的节点名称
	//
	// Node name applied by default.
	AppNodeName string

	// CurrentLang
	//
	// 当前语言
	//
	// Current language
	CurrentLang string
)

Functions

func ChangeLang

func ChangeLang(lang string)

ChangeLang

改变语言
Change language.

func I18NInit

func I18NInit()

func IdRes

func IdRes(key string) string

IdRes

通过key查询当前资源中的,顺序为当前app资源 -> 共享资源 -> lib资源
Query the current resources by key, the order is current app resources -> shared resources -> lib resources.

func InitComponentLang

func InitComponentLang(aOwner lcl.IComponent)

InitComponentLang

初始一个Form的语言
The language of the initial Form.

func InitDefaultLang

func InitDefaultLang()

InitDefaultLang

初始默认语言
Initial default language.

func ReadSetLang

func ReadSetLang() string

ReadSetLang

读当前强制显示语言
Read the current mandatory display language.

func RegisterVarString

func RegisterVarString(name string, value *string)

RegisterVarString

注册需要翻译的字符
Register characters that need to be translated.

func WriteSetLang

func WriteSetLang(lang string)

WriteSetLang

写入强显示制语言
Write mandatory language.

Types

type TLangItem

type TLangItem struct {
	Language struct {
		Id          int    // 2052
		Name        string // zh-CN
		Description string // 简体中文
		Author      string // ying32
		AuthorEmail string // 1444386932@qq.com

	} `json:"!language"`
}

TLangItem

本地已经存在语言列表的项目定义

Jump to

Keyboard shortcuts

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