Internationalization

Most of the internal documentation for alauda is bilingual in Chinese and English. Therefore, we default to supporting the use of en/zh subfolders to store documentation in different languages. It is recommended to also store static resources in en/zh subfolders under the public directory, which facilitates the management of documentation content and static resources.

TOC

i18n.json

For reusable components that need to support both Chinese and English within the same component, you must first create an i18n.json file in the docs directory. Then, you can use useI18n in the component to retrieve the text in the current language, for example:

{
  "title": {
    "zh": "标题",
    "en": "Title"
  },
  "description": {
    "zh": "描述",
    "en": "description"
  }
}

.ts/.tsx

import { useI18n } from '@rspress/runtime'

export const CommonContent = () => {
  const t = useI18n()
  return <h1>{t('title')}</h1>
}

.mdx

import { useI18n } from '@rspress/runtime'

# {useI18n()('title')}

{useI18n()('description')}