11package state
22
3- // LangPack ...
4- type LangPack struct {
3+ import "fmt"
4+
5+ func LoadLanguage (language string ) LangPack {
6+ if l , ok := langs [language ]; ok {
7+ return l
8+ }
9+ return langEn
10+ }
11+
12+ // langPack ...
13+ type langPack struct {
514 Hints map [State ]string
615 Rule string
716}
817
18+ func (l * langPack ) GetHint (state State , v ... interface {}) string {
19+ return fmt .Sprintf (l .Hints [state ], v ... )
20+ }
21+
22+ func (l * langPack ) GetRule (types string ) string {
23+ return fmt .Sprintf (l .Rule , types )
24+ }
25+
926var (
10- langEn = & LangPack {
27+ langEn = & langPack {
1128 Hints : map [State ]string {
12- Validated : "Validated: commit message meet the rule.\n " ,
13- Merge : "Merge: merge commit detected,skip check.\n " ,
14- ArgumentMissing : "Error ArgumentMissing: commit message file argument missing.\n " ,
15- FileMissing : "Error FileMissing: file %s not exists.\n " ,
16- ReadError : "Error ReadError: read file %s error.\n " ,
17- EmptyMessage : "Error EmptyMessage: commit message has no content except whitespaces.\n " ,
18- EmptyHeader : "Error EmptyHeader: header (first line) has no content except whitespaces.\n " ,
29+ Validated : "Validated: commit message meet the rule." ,
30+ Merge : "Merge: merge commit detected,skip check." ,
31+ ArgumentMissing : "Error ArgumentMissing: commit message file argument missing." ,
32+ FileMissing : "Error FileMissing: file %s not exists." ,
33+ ReadError : "Error ReadError: read file %s error." ,
34+ EmptyMessage : "Error EmptyMessage: commit message has no content except whitespaces." ,
35+ EmptyHeader : "Error EmptyHeader: header (first line) has no content except whitespaces." ,
1936 BadHeaderFormat : `Error BadHeaderFormat: header (first line) not following the rule:
2037 %s
2138 if you can not find any error after check, maybe you use Chinese colon, or lack of whitespace after the colon.` ,
22- WrongType : "Error WrongType: %s, type should be one of the keywords:\n %s\n " ,
23- ScopeMissing : "Error ScopeMissing: (scope) is required right after type.\n " ,
24- WrongScope : "Error WrongScope: %s, scope should be one of the keywords:\n %s\n " ,
25- BodyMissing : "Error BodyMissing: body has no content except whitespaces.\n " ,
26- NoBlankLineBeforeBody : "Error NoBlankLineBeforeBody: no empty line between header and body.\n " ,
27- LineOverLong : "Error LineOverLong: the length of line is %d, exceed %d:\n %s\n " ,
28- UndefindedError : "Error UndefindedError: unexpected error occurs, please raise an issue.\n " ,
39+ WrongType : "Error WrongType: %s, type should be one of the keywords:\n %s" ,
40+ ScopeMissing : "Error ScopeMissing: (scope) is required right after type." ,
41+ WrongScope : "Error WrongScope: %s, scope should be one of the keywords:\n %s" ,
42+ BodyMissing : "Error BodyMissing: body has no content except whitespaces." ,
43+ NoBlankLineBeforeBody : "Error NoBlankLineBeforeBody: no empty line between header and body." ,
44+ LineOverLong : "Error LineOverLong: the length of line is %d, exceed %d:\n %s" ,
45+ UndefindedError : "Error UndefindedError: unexpected error occurs, please raise an issue." ,
2946 },
3047 Rule : `Commit message rule as follow:
3148 <type>(<scope>): <subject>
@@ -39,25 +56,25 @@ var (
3956 more specific instructions, please refer to: https://github.com/JayceChant/commit-msg` ,
4057 }
4158
42- langZhCn = & LangPack {
59+ langZhCn = & langPack {
4360 Hints : map [State ]string {
44- Validated : "Validated: 提交信息符合规范。\n " ,
45- Merge : "Merge: 合并提交,跳过规范检查。\n " ,
46- ArgumentMissing : "Error ArgumentMissing: 缺少文件参数。\n " ,
47- FileMissing : "Error FileMissing: 文件 %s 不存在。\n " ,
48- ReadError : "Error ReadError: 读取 %s 错误。\n " ,
49- EmptyMessage : "Error EmptyMessage: 提交信息没有内容(不包括空白字符)。\n " ,
50- EmptyHeader : "Error EmptyHeader: 标题(第一行)没有内容(不包括空白字符)。\n " ,
61+ Validated : "Validated: 提交信息符合规范。" ,
62+ Merge : "Merge: 合并提交,跳过规范检查。" ,
63+ ArgumentMissing : "Error ArgumentMissing: 缺少文件参数。" ,
64+ FileMissing : "Error FileMissing: 文件 %s 不存在。" ,
65+ ReadError : "Error ReadError: 读取 %s 错误。" ,
66+ EmptyMessage : "Error EmptyMessage: 提交信息没有内容(不包括空白字符)。" ,
67+ EmptyHeader : "Error EmptyHeader: 标题(第一行)没有内容(不包括空白字符)。" ,
5168 BadHeaderFormat : `Error BadHeaderFormat: 标题(第一行)不符合规范:
5269 %s
5370 如果您无法发现错误,请注意是否使用了中文冒号,或者冒号后面缺少空格。` ,
54- WrongType : "Error WrongType: %s, 类型关键字应为以下选项中的一个:\n %s\n " ,
55- ScopeMissing : "Error ScopeMissing: 类型后面缺少'(scope)'。\n " ,
56- WrongScope : "Error WrongScope: %s, 范围关键字应为以下选项中的一个:\n %s\n " ,
57- BodyMissing : "Error BodyMissing: 消息体没有内容(不包括空白字符)。\n " ,
58- NoBlankLineBeforeBody : "Error NoBlankLineBeforeBody: 标题和消息体之间缺少空行。\n " ,
59- LineOverLong : "Error LineOverLong: 该行长度为 %d, 超出了 %d 的限制:\n %s\n " ,
60- UndefindedError : "Error UndefindedError: 没有预料到的错误,请提交一个错误报告。\n " ,
71+ WrongType : "Error WrongType: %s, 类型关键字应为以下选项中的一个:\n %s" ,
72+ ScopeMissing : "Error ScopeMissing: 类型后面缺少'(scope)'。" ,
73+ WrongScope : "Error WrongScope: %s, 范围关键字应为以下选项中的一个:\n %s" ,
74+ BodyMissing : "Error BodyMissing: 消息体没有内容(不包括空白字符)。" ,
75+ NoBlankLineBeforeBody : "Error NoBlankLineBeforeBody: 标题和消息体之间缺少空行。" ,
76+ LineOverLong : "Error LineOverLong: 该行长度为 %d, 超出了 %d 的限制:\n %s" ,
77+ UndefindedError : "Error UndefindedError: 没有预料到的错误,请提交一个错误报告。" ,
6178 },
6279 Rule : `提交信息规范如下:
6380 <type>(<scope>): <subject>
7188 更多信息,请参考项目主页: https://github.com/JayceChant/commit-msg` ,
7289 }
7390
74- langs = map [string ]* LangPack {
91+ langs = map [string ]* langPack {
7592 "en" : langEn ,
7693 "zh" : langZhCn ,
7794 "zh-CN" : langZhCn ,
0 commit comments