Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (41 sloc) 1.33 KB
title layout
Internationalization
docs

URL-Based I18n Solution

To leverage multi-language support in Saber, you first need to use the following file structure in your pages folder:

pages/
├─ index.md
├─ foo.md
├─ nested
│  └─ index.md
├─ cn
│  ├─ index.md
│  ├─ foo.md
│  └─ nested
│     └─ index.md
└─ fr
   ├─ index.md
   ├─ foo.md
   └─ nested
      └─ index.md

In this way, the cn (Chinese) version of your site is available under the path /cn, the fr (French) version of your site is available under the path /fr.

Then, specify the locales option in your saber-config.yml:

siteConfig:
  lang: en
  title: My Site

locales:
  /cn:
    siteConfig:
      lang: zh
      title: 我的网站
  /fr:
    siteConfig:
      lang: fr
      title: Mon Site

The siteConfig.lang option is used to set the lang attribute for <html> element.

The locales option is used to override siteConfig and themeConfig for specific paths. For example, when you visit the homepage / or /about page, this.$siteConfig.title in your component will be My Site, while if you visit /cn or /cn/about, it will be 我的网站 instead.

You can’t perform that action at this time.