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/i18nopen in new window.

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: nickname
    • mail: Email
    • link: Link
    • placeholder: Default text of comment box
    • sofa: Display text when the comment area is empty
    • submit: Submit button text
    • comment: Comment button text
    • more: Load more button text
    • uploading: display text when uploading
    • login: login button text
    • admin: The label of the administrator
    • word: word

    Info

    The above text will be displayed in page.

  • Prompt information related:

    • nickError: Error message that the nickname does not meet the conditions
    • mailError: The error message that the mailbox does not meet the conditions
    • wordHint: 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 ago
    • minutes: minutes ago
    • hours: hours ago
    • days: days ago
    • now: just now
  • Accessibility related:

    • reply: the label text of the reply button
    • cancelReply: the label text of the cancel reply button
    • preview: Preview button label text
    • emoji: the label text of the emoji button
    • uploadImage: the label text of the upload image button
    • logout: 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.
Comments
Powered by Waline v2.6.1