lang

package
v0.0.0-...-bcece33 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

书面、音频、字母等语言信息 ref:

https://en.wikipedia.org/wiki/ISO_639
https://en.wikipedia.org/wiki/ISO_639_macrolanguage
https://en.wikipedia.org/wiki/IETF_language_tag
https://www.rfc-editor.org/rfc/rfc4646

Index

Constants

View Source
const (
	Mandarin           = "Mandarin"
	MandarinCode       = "cmn"
	MandarinNativeName = "汉语普通话"
)
View Source
const (
	Cantonese           = "Cantonese"
	CantoneseCode       = "yue"
	CantoneseNativeName = "粵語"
)
View Source
const (
	SimplifiedChinese           = "Simplified Chinese"
	SimplifiedChineseCode       = "zh-Hans"
	SimplifiedChineseNativeName = "简体中文"
)
View Source
const (
	Chinese           = "Chinese"
	ChineseCode       = "zh"
	ChineseNativeName = "中文"
)
View Source
const (
	English           = "English"
	EnglishCode       = "en"
	EnglishNativeName = "English"
)

shortcut consts

View Source
const (
	TraditionalChinese           = "Traditional Chinese"
	TraditionalChineseCode       = "zh-Hant"
	TraditionalChineseNativeName = "正體中文"
)

Variables

View Source
var (
	CantoneseInfo = &ExtInfo{
		Name:       Cantonese,
		NativeName: CantoneseNativeName,
		Code:       CantoneseCode,
	}
)
View Source
var (
	ChineseInfo = SimplifiedChineseInfo
)
View Source
var (
	MandarinInfo = &ExtInfo{
		Name:       Mandarin,
		NativeName: MandarinNativeName,
		Code:       MandarinCode,
	}
)
View Source
var (
	SimplifiedChineseInfo = &ExtInfo{
		Name:       SimplifiedChinese,
		NativeName: SimplifiedChineseNativeName,
		Code:       SimplifiedChineseCode,
	}
)
View Source
var (
	TraditionalChineseInfo = &ExtInfo{
		Name:       TraditionalChinese,
		NativeName: TraditionalChineseNativeName,
		Code:       TraditionalChineseCode,
	}
)

Functions

This section is empty.

Types

type ExtInfo

type ExtInfo struct {
	// 英文简短名. 例: Mandarin
	Name string

	// 本地化语言值。例:汉语普通话
	NativeName string

	// ISO code(例:cmn) 或 IETF language tag(zh-cn zh-Hant) 值,优先级为哪个有更确切定义则优先使用哪一个。
	//   例1:Cantonese	粤语,ISO-639-1 定义为 zh,639-2 为 chi/zho,639-3 type individual 为 yue,
	//     IETF language tag 只能笼统用 zh-Hant 代替,则应该用更精准的 yue 定义。
	//   例2:Simplified Chinese 简体中文,ISO-639 无精准定义,只能用最相近的 zh/zho 代替;IETF language tag 为 zh-hans,则应用更精准的 zh-hans 定义。
	Code string
}

func NewFromCode

func NewFromCode(s string) (rs *ExtInfo)

func NewFromName

func NewFromName(s string) (rs *ExtInfo)

func NewFromNativeName

func NewFromNativeName(s string) (rs *ExtInfo)

Jump to

Keyboard shortcuts

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