Skip to content

Commit

Permalink
Added supports of russian language
Browse files Browse the repository at this point in the history
fixed:
  - bug when entered "c" or "s" useHotkeys
  - when enableComment option disabled, block with comments not hidden
  • Loading branch information
SerRashin committed Nov 19, 2024
1 parent 37847a3 commit 58a496c
Show file tree
Hide file tree
Showing 10 changed files with 799 additions and 61 deletions.
3 changes: 2 additions & 1 deletion src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const options = $ref({
},
document: {
// title: '测试文档',
content: localStorage.getItem('document.content') ?? '<p>测试文档</p>',
content: localStorage.getItem('document.content') ?? '<p>Введите текст</p>',
enableComment: false
},
templates,
cdnUrl: 'https://cdn.umodoc.com',
Expand Down
6 changes: 4 additions & 2 deletions src/components/container/page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
</template>
</editor>
</div>
<container-comments />
<template v-if="options.document?.enableComment">
<container-comments />
</template>
</div>
</div>
<t-image-viewer
Expand All @@ -49,7 +51,7 @@
</template>

<script setup lang="ts">
const { container, page, imageViewer } = useStore()
const { container, page, imageViewer, options } = useStore()
// 页面大小
const pageSize = $computed(() => {
Expand Down
6 changes: 4 additions & 2 deletions src/components/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import domToImage from 'dom-to-image-more'
import type { GlobalConfigProvider } from 'tdesign-vue-next'
import enConfig from 'tdesign-vue-next/esm/locale/en_US'
import cnConfig from 'tdesign-vue-next/esm/locale/zh_CN'
import ruConfig from 'tdesign-vue-next/esm/locale/ru_RU'
import { getSelectionNode, getSelectionText } from '@/extensions/selection'
import { i18n } from '@/i18n'
Expand Down Expand Up @@ -322,6 +323,7 @@ watch(
const localeConfig = $ref<Record<string, GlobalConfigProvider>>({
'zh-CN': cnConfig as unknown as GlobalConfigProvider,
'en-US': enConfig as unknown as GlobalConfigProvider,
'ru-RU': ruConfig as unknown as GlobalConfigProvider,
})
// Page Header/Footer Visibility
Expand Down Expand Up @@ -594,8 +596,8 @@ const autoPagination = (enabled: boolean) => {
// Locale Methods
const setLocale = (params: SupportedLocale) => {
if (!['zh-CN', 'en-US'].includes(params)) {
throw new Error('"params" must be one of "zh-CN" or "en-US".')
if (!['zh-CN', 'en-US', 'ru-RU'].includes(params)) {
throw new Error('"params" must be one of "zh-CN", "en-US" or "ru-RU".')
}
if (locale.value === params) {
return
Expand Down
3 changes: 2 additions & 1 deletion src/components/statusbar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ const autoWidth = (auto = true, padding = 50) => {
console.warn('Page auto width calculation error', e)
}
}
useHotkeys('Ctrl0,command+0', autoWidth)
useHotkeys('Ctrl+0,command+0', autoWidth)
watch(
() => page.value.showToc,
Expand All @@ -489,6 +489,7 @@ watch(
const langs = [
{ content: '🇨🇳 简体中文', value: 'zh-CN' },
{ content: '🇱🇷 English', value: 'en-US' },
{ content: '🇷🇺 Русский', value: 'ru-RU' },
]
const setLocale = inject('setLocale') as (value: SupportedLocale) => void
Expand Down
2 changes: 2 additions & 0 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { SupportedLocale } from '@/types'

import en_US from './locales/en-US.json'
import zh_CN from './locales/zh-CN.json'
import ru_RU from './locales/ru-RU.json'

const { options } = useStore()

Expand All @@ -24,5 +25,6 @@ export const i18n = createI18n({
messages: {
'en-US': merge(en_US, getLocale('en-US')),
'zh-CN': merge(zh_CN, getLocale('zh-CN')),
'ru-RU': merge(ru_RU, getLocale('ru-RU')),
},
})
Loading

0 comments on commit 58a496c

Please sign in to comment.