Internationalization

Mr.Hope ... April 7, 2021 14:47 Config
  • Config
  • I18n
Less than 1 minute

# Root lang config

You should add locales key in .vuepress/config.js, and set locales["/"].lang. Then the theme can understand which language is the root docs written in:

Tips

// .vuepress/config.js
const { config } = require("vuepress-theme-hope");

module.exports = config({
  locales: {
    "/": {
      // Set the language you need
      lang: "en-US",
    },
  },
});
1
2
3
4
5
6
7
8
9
10
11

# Internationalization

locales is an object whose key is the path prefix of each language, and value is the configuration of this language. The value object can include title, description, lang, etc.

Info

For details of multiple languages, please see [Official Document] (https://v1.vuepress.vuejs.org/zh/guide/i18n.html (opens new window))

If the locales and themeConfig.locales objects only contain the "/" key, the theme will not display the multilingual dropdown menu. When you set multiple keys through locales, that is, when there are multiple languages, we will display a multilingual dropdown menu in the upper right corner of navbar.

# Internationalization Support

Only Simplified Chinese (zh-CN), English (United States) (en-US), German (de-AT) and Vietnamese (vi-VN) are available for i18n.

If you need multi-language support for other languages, welcome to submit a PR to this file (opens new window) and other files named i18n.ts in this repo.