-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
packages/docs/fluent-editor/.vitepress/components/TranslateComponent.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts" setup> | ||
import { ref, onMounted } from 'vue' | ||
const currentLang = ref('chinese_simplified') | ||
onMounted(() => { | ||
setTimeout(() => { | ||
currentLang.value = translate.language.getCurrent() | ||
}, 3000) | ||
}) | ||
const switchLang = () => { | ||
if (translate.language.getCurrent() === 'chinese_simplified') { | ||
translate.changeLanguage('english') | ||
currentLang.value = 'english' | ||
} else { | ||
translate.changeLanguage('chinese_simplified') | ||
currentLang.value = 'chinese_simplified' | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="translate-switch"> | ||
<a @click="switchLang">{{ currentLang === 'english' ? 'English' : '简体中文' }}</a> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.translate-switch { | ||
display: flex; | ||
align-items: center; | ||
font-size: 14px; | ||
cursor: pointer; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/docs/fluent-editor/.vitepress/theme/insert-translate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export function insertTranslate() { | ||
if (typeof document === 'undefined') return | ||
const translateScript = document.createElement('script') | ||
const translateScriptStr = ` | ||
translate.language.setLocal('chinese_simplified'); | ||
translate.service.use('client.edge'); | ||
translate.listener.start(); | ||
translate.setAutoDiscriminateLocalLanguage(); | ||
translate.selectLanguageTag.languages = 'english,chinese_simplified'; | ||
translate.selectLanguageTag.show = false; | ||
translate.language.setDefaultTo('chinese_simplified'); | ||
translate.ignore.class.push('ql-container'); | ||
translate.ignore.class.push('ql-editor'); | ||
translate.ignore.class.push('petercat-lui-assistant'); | ||
translate.ignore.class.push('translate-switch'); | ||
translate.execute(); | ||
` | ||
translateScript.textContent = translateScriptStr | ||
document.body.append(translateScript) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,3 +98,8 @@ | |
padding-top: 0; | ||
line-height: 22px; | ||
} | ||
|
||
/* 翻译工具 */ | ||
#translate { | ||
display: none; | ||
} |