I18n Support
About 2 min...
Waline has built-in multi-language support, and you can also customize Waline's locale config.
Basic Usage
You can set the language used by Waline through the lang
option. The supported languages are:
- zh
- zh-CN
- zh-TW
- en
- en-US
- jp
- jp-JP
- pt-BR
- ru
- ru-RU
E.g.:
Waline.init({
el: '#waline',
// ...
lang: 'en',
});
Tips
If you want to help Waline add more language support, we welcome you to send a PR to client/config/i18n.
Customize
You can customize the language through the locale
option, or set some fields to overwrite the existing UI text.
locale
option
UI related:
nick
: nicknamemail
: Emaillink
: Linkplaceholder
: Default text of comment boxsofa
: Display text when the comment area is emptysubmit
: Submit button textcomment
: Comment button textmore
: Load more button textuploading
: display text when uploadinglogin
: login button textadmin
: The label of the administratorword
: word
Info
The above text will be displayed in page.
Prompt information related:
nickError
: Error message that the nickname does not meet the conditionsmailError
: The error message that the mailbox does not meet the conditionswordHint
: Error prompt for comment word count, where$0
$1
$2
will be automatically replaced with the lower limit of the allowed word count, the upper limit of the allowed word count, and the current word count.
Comment time related:
seconds
: seconds agominutes
: minutes agohours
: hours agodays
: days agonow
: just now
Accessibility related:
reply
: the label text of the reply buttoncancelReply
: the label text of the cancel reply buttonpreview
: Preview button label textemoji
: the label text of the emoji buttonuploadImage
: the label text of the upload image buttonlogout
: the label text of the logout button
Info
These texts are only for accessibility purpose and will not be displayed on the page.
Example
// en default
const locale = {
nick: 'NickName',
nickError: 'NickName cannot be less than 3 bytes.',
mail: 'E-Mail',
mailError: 'Please confirm your email address.',
link: 'Website',
placeholder: 'Comment here...',
sofa: 'No comment yet.',
submit: 'Submit',
reply: 'Reply',
cancelReply: 'Cancel reply',
comment: 'Comments',
more: 'Load More...',
preview: 'Preview',
emoji: 'Emoji',
uploadImage: 'Upload Image',
seconds: 'seconds ago',
minutes: 'minutes ago',
hours: 'hours ago',
days: 'days ago',
now: 'just now',
uploading: 'Uploading',
login: 'Login',
logout: 'logout',
admin: 'Admin',
word: 'Words',
wordHint:
'Please input comments between $0 and $1 words!\n Current word number: $2',
};
Waline.init({
el: '#waline',
path: location.pathname,
serverURL: 'YOUR_SERVER_URL',
// ...
locale,
});
TIPS: The comment area is only for demo. If you have any questions, please go to Github Discussion to ask.