You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. state.State implements Stringer, TextMarshaler and TextUnmarshaler
2. language can be loaded from translation file
3. add sample translation
4. Makefile and README
Copy file name to clipboardExpand all lines: README.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,30 @@ If there are no configuration files, the program will use the following default
101
101
}
102
102
```
103
103
104
+
## Localization
105
+
106
+
The program has built-in two languages: English (en) and Chinese (zh).
107
+
108
+
You can add language support in two ways:
109
+
110
+
### Contributing code
111
+
112
+
The built-in languages are placed in the `lang` directory, with individual `.go` source file for each. You can copy `lang/english.go`, change the file name and translate the content, then commit it to launch a Pull Request. The language will be added in next release after the PR is approved.
113
+
114
+
Of course, considering my limited English (my Chinese wording is not necessarily good either), you can also help improve the existing language support.
115
+
116
+
### Add translation file
117
+
118
+
However, committing code may not be the best way to go.
119
+
120
+
Firstly , committing code is time-consuming. If you can't compile it yourself, but have to wait for next version release after the code merged in, it would be a long time until the version is ready. On the other hand, this is only a small tool after all, and to avoid the program becoming bloated, some languages may not be merged in, depending on the number of users.
121
+
122
+
You can choose a quicker way: adding translation file.
123
+
124
+
To do this, copy the [commit-msg.en.json.sample](./commit-msg.en.json.sample) file in the project root directory, remove `.sample` from the file name, and change `en` to the corresponding language (e.g., the abbreviation for language to be supported is `xx`) . Translate the contents of the file, keeping the formatting verb `%s` and the line break `\n`. Then put the file in the same directory as the configuration file (`home` directory or `hooks` directory). Afterwards, remember to change the language configuration to the corresponding language (`xx` in this case).
125
+
126
+
Unlike the configuration file, if the translations for the same language exist in both `home` directory and `hooks` directory, the contents of both will not be merged, but the translation in `hooks` directory of the project will prevail. The contents of each language file must be a complete translation.
127
+
104
128
## More info
105
129
106
130
The project was first inspired by [validate-commit-msg](https://github.com/conventional-changelog-archived-repos/validate-commit-msg) . ( It has now been moved to [conventional-changelog/commitlint](https://github.com/conventional-changelog/commitlint) )
"EmptyMessage": "Error EmptyMessage: commit message has no content except whitespaces.",
10
+
"EmptyHeader": "Error EmptyHeader: header (first line) has no content except whitespaces.",
11
+
"BadHeaderFormat": "Error BadHeaderFormat: header (first line) not following the rule:\n%s\nif you can not find any error after check, maybe you use full-width colon, or lack of whitespace after the colon.",
12
+
"WrongType": "Error WrongType: %s, type should be one of the keywords:\n%s",
13
+
"ScopeMissing": "Error ScopeMissing: (scope) is required right after type.",
14
+
"WrongScope": "Error WrongScope: %s, scope should be one of the keywords:\n%s",
15
+
"BodyMissing": "Error BodyMissing: body has no content except whitespaces.",
16
+
"NoBlankLineBeforeBody": "Error NoBlankLineBeforeBody: no empty line between header and body.",
17
+
"LineOverLong": "Error LineOverLong: the length of line is %d, exceed %d:\n%s",
18
+
"UndefindedError": "Error UndefindedError: unexpected error occurs, please raise an issue."
19
+
},
20
+
"rule": "Commit message rule as follow:\n<type>(<scope>): <subject>\n// empty line\n<body>\n// empty line\n<footer>\n\n(<scope>), <body> and <footer> are optional by default\n<type> must be one of %s\nmore specific instructions, please refer to: https://github.com/JayceChant/commit-msg"
0 commit comments