11import { defineConfig } from 'vitepress'
2- import { search as zhSearch } from './zh'
3- import { search as ptSearch } from './pt'
4- import { search as ruSearch } from './ru'
52import { search as esSearch } from './es'
6- import { search as koSearch } from './ko'
73import { search as faSearch } from './fa'
4+ import { search as koSearch } from './ko'
5+ import { search as ptSearch } from './pt'
6+ import { search as ruSearch } from './ru'
7+ import { search as zhSearch } from './zh'
88
99export const shared = defineConfig ( {
1010 title : 'VitePress' ,
@@ -26,7 +26,36 @@ export const shared = defineConfig({
2626 return code . replace ( / \[ \! \! c o d e / g, '[!code' )
2727 }
2828 }
29- ]
29+ ] ,
30+ config ( md ) {
31+ // TODO: remove when https://github.com/vuejs/vitepress/issues/4431 is fixed
32+ const fence = md . renderer . rules . fence !
33+ md . renderer . rules . fence = function ( tokens , idx , options , env , self ) {
34+ const { localeIndex = 'root' } = env
35+ const codeCopyButtonTitle = ( ( ) => {
36+ switch ( localeIndex ) {
37+ case 'es' :
38+ return 'Copiar código'
39+ case 'fa' :
40+ return 'کپی کد'
41+ case 'ko' :
42+ return '코드 복사'
43+ case 'pt' :
44+ return 'Copiar código'
45+ case 'ru' :
46+ return 'Скопировать код'
47+ case 'zh' :
48+ return '复制代码'
49+ default :
50+ return 'Copy code'
51+ }
52+ } ) ( )
53+ return fence ( tokens , idx , options , env , self ) . replace (
54+ '<button title="Copy Code" class="copy"></button>' ,
55+ `<button title="${ codeCopyButtonTitle } " class="copy"></button>`
56+ )
57+ }
58+ }
3059 } ,
3160
3261 sitemap : {
0 commit comments