Fumapress
The site generator

Internationalization

Internationalize your Fumapress app.

Setup

To configure internationalization, define an i18n config:

press.config.tsx
import { defineConfig } from "fumapress";
import { docs } from "./.source/server";
import { defineI18n } from "fumadocs-core/i18n";
import { uiTranslations } from "fumadocs-ui/i18n";
import { fumapressTranslations } from "fumapress/i18n";

const i18n = defineI18n({
  languages: ["cn", "en"],
  defaultLanguage: "en",
});

const translations = i18n
  .translations()
  .extend(uiTranslations())
  .extend(fumapressTranslations());

export default defineConfig({
  content: docs.toFumadocsSource(),
  translations,
});

You can add translations to UI like:

const translations = i18n
  .translations()
  .extend(uiTranslations())
  .extend(fumapressTranslations())
  .add({
    en: { displayName: "English" },
    cn: {
      displayName: "Chinese",
      "Search(search dialog)": "搜尋文檔",
      "Blog(blog)": "博客",
      "All Tags(blog tags page)": "全部标签",
    },
  });

If you have other integrations and want to add translations for them, include them via extend() like:

import { openapiTranslations } from "fumadocs-openapi/i18n";
import { aiTranslations } from "@fumapress/ai/i18n";
import { feedbackTranslations } from "@fumapress/feedback/i18n";

const translations = i18n
  .translations()
  .extend(uiTranslations())
  .extend(fumapressTranslations())
  .extend(openapiTranslations())
  .extend(feedbackTranslations())
  .extend(aiTranslations());

Using Language Packs

The official language pack extends @fumadocs/language and adds translations for Fumapress.

npm i @fumapress/language
press.config.tsx
import { zhCN } from "@fumapress/language/zh-cn";

const translations = i18n
  .translations()
  // add Traditional Chinese translations to `cn` locale
  .preset("cn", zhCN());

When using a language pack, you do not need to include integrations with extend() unless you want to override the default translations.

Learn More

See Fumadocs Translations API for adding translations.

Writing Content

Add Markdown/JSON files for different languages by attending .{locale} to your file name, like:

meta.json
meta.cn.json
get-started.mdx
get-started.cn.mdx

Last updated on

On this page