vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.31k stars 2.15k forks source link

i18n with markdown containers #3861

Open brc-dd opened 7 months ago

brc-dd commented 7 months ago

similar to vuepress

its-miroma commented 5 months ago

Currently, Markdown Containers' titles can be changed in a markdown option in the configuration (source), however that does not allow localisation.

Reproduction

https://stackblitz.com/edit/vite-cece3h?file=docs%2F.vitepress%2Fconfig.ts

.vitepress/config.ts ```ts import { defineConfig } from 'vitepress'; export default defineConfig({ locales: { root: { label: 'English', lang: 'en', link: '/', title: 'VitePress - English', }, fr: { label: 'Français', lang: 'fr', link: '/fr/', title: 'VitePress - Français', }, }, markdown: { container: { tipLabel: 'CUSTOM TIP', }, }, }); ```
index.md ```md --- layout: home hero: name: VitePress - English --- ::: tip ^^^ Not translatable ^^^ ::: ::: tip CUSTOM TIP: Title ^^^ Workaround ^^^ ::: ```
fr/index.md ```md --- layout: home hero: name: VitePress - Français --- ::: tip ^^^ Intraduisible ^^^ ::: ::: tip CONSEIL PERSONNALISÉ: Titre ^^^ Solution de contournement ^^^ ::: ```

Expected behavior

.vitepress/config.ts ```ts import { defineConfig } from 'vitepress'; export default defineConfig({ locales: { root: { label: 'English', lang: 'en', link: '/', themeConfig: { markdown: { container: { tipLabel: 'CUSTOM TIP', }, }, }, title: 'VitePress - English', }, fr: { label: 'Français', lang: 'fr', link: '/fr/', themeConfig: { markdown: { container: { tipLabel: 'CONSEIL PERSONNALISÉ', }, }, }, title: 'VitePress - Français', }, }, }); ```