feat(Tiptap): add internationalization support for word and length display in multiple languages

This commit is contained in:
keven1024
2026-05-24 18:18:20 +08:00
parent 7128a8c329
commit 1fdd05f0ea
8 changed files with 23 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ import { Markdown } from 'tiptap-markdown'
import Placeholder from '@tiptap/extension-placeholder'
import { cx } from 'class-variance-authority'
import countWords from '@/lib/countWords'
const { t } = useI18n()
const props = defineProps<{
modelValue?: string
@@ -64,6 +65,6 @@ onUnmounted(() => {
v-if="modelValue?.length && modelValue?.length > 0"
class="absolute bottom-2 right-3 flex justify-end px-2 py-1 text-xs text-gray-400 select-none bg-white rounded-md"
>
{{ `${modelValue?.length ?? 0} 长度 · ${countWords(modelValue ?? '')} 字符` }}
{{ `${modelValue?.length ?? 0} ${t('common.length')} · ${countWords(modelValue ?? '')} ${t('common.words')}` }}
</div>
</template>

View File

@@ -38,7 +38,9 @@
},
"common": {
"add": "Hinzufügen",
"copySuccess": "Erfolgreich kopiert"
"copySuccess": "Erfolgreich kopiert",
"length": "Länge",
"words": "Wörter"
},
"page": {
"upload": {

View File

@@ -38,7 +38,9 @@
},
"common": {
"add": "Add",
"copySuccess": "Copy Success"
"copySuccess": "Copy Success",
"length": "length",
"words": "words"
},
"page": {
"upload": {

View File

@@ -38,7 +38,9 @@
},
"common": {
"add": "Ajouter",
"copySuccess": "Copié avec succès"
"copySuccess": "Copié avec succès",
"length": "longueur",
"words": "mots"
},
"page": {
"upload": {

View File

@@ -38,7 +38,9 @@
},
"common": {
"add": "追加",
"copySuccess": "コピーしました"
"copySuccess": "コピーしました",
"length": "長さ",
"words": "文字"
},
"page": {
"upload": {

View File

@@ -38,7 +38,9 @@
},
"common": {
"add": "추가",
"copySuccess": "복사되었습니다"
"copySuccess": "복사되었습니다",
"length": "길이",
"words": "단어"
},
"page": {
"upload": {

View File

@@ -38,7 +38,9 @@
},
"common": {
"add": "添加",
"copySuccess": "复制成功"
"copySuccess": "复制成功",
"length": "长度",
"words": "字符"
},
"page": {
"upload": {

View File

@@ -38,7 +38,9 @@
},
"common": {
"add": "新增",
"copySuccess": "複製成功"
"copySuccess": "複製成功",
"length": "長度",
"words": "字符"
},
"page": {
"upload": {