mirror of https://github.com/YunYouJun/valaxy
feat: defu merge i18n locales for docs
This commit is contained in:
parent
962cb25a3f
commit
3fd37ea0b7
|
@ -89,3 +89,6 @@ features:
|
|||
electron:
|
||||
title: Electron - Desktop Applications
|
||||
details: In the future, we will also release a client application for non-developers, making development, deployment, and publishing more convenient. Stay tuned...
|
||||
|
||||
tooltip:
|
||||
edit_this_page: Edit this page on GitHub
|
||||
|
|
|
@ -89,3 +89,6 @@ features:
|
|||
electron:
|
||||
title: Electron - 客户端应用
|
||||
details: 在未来我们还将推出面向非开发者的客户端,让你从开发、部署到发布更加便捷,敬请期待……
|
||||
|
||||
tooltip:
|
||||
edit_this_page: 在 GitHub 上编辑此页
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
<script lang="ts" setup>
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useEditLink } from '../composables'
|
||||
|
||||
const editLink = useEditLink()
|
||||
|
||||
const { t } = useI18n()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div flex justify="between" text="sm">
|
||||
<a flex items="center" :href="editLink.url" target="_blank">
|
||||
<div i-ri-external-link-line />
|
||||
<span ml-1>{{ editLink.text }}</span>
|
||||
<span ml-1>{{ editLink.text || t('tooltip.edit_this_page') }}</span>
|
||||
</a>
|
||||
<PressDocFooterLastUpdated />
|
||||
</div>
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watchEffect } from 'vue'
|
||||
import { useData, useThemeConfig } from 'valaxy'
|
||||
import type { PressTheme } from '../types'
|
||||
import { useData } from 'valaxy'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const data = useData()
|
||||
const themeConfig = useThemeConfig<PressTheme.Config>()
|
||||
|
||||
const date = computed(() => new Date(data.lastUpdated!))
|
||||
const isoDatetime = computed(() => date.value.toISOString())
|
||||
|
@ -18,11 +17,12 @@ onMounted(() => {
|
|||
datetime.value = date.value.toLocaleString(window.navigator.language)
|
||||
})
|
||||
})
|
||||
const { t } = useI18n()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<p class="press-lastUpdated">
|
||||
{{ themeConfig.lastUpdatedText ?? 'Last updated' }}:
|
||||
{{ t('tooltip.last_updated') }}:
|
||||
<time :datetime="isoDatetime">{{ datetime }}</time>
|
||||
</p>
|
||||
</template>
|
||||
|
|
|
@ -5,7 +5,7 @@ import { useThemeConfig } from '.'
|
|||
export function useEditLink() {
|
||||
const themeConfig = useThemeConfig()
|
||||
return computed(() => {
|
||||
const { text = 'Edit this page', pattern } = themeConfig.value.editLink || {}
|
||||
const { text, pattern } = themeConfig.value.editLink || {}
|
||||
const { relativePath } = useData()
|
||||
const url = pattern.replace(/:path/g, relativePath)
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ export const defaultThemeConfig: ThemeConfig = {
|
|||
|
||||
editLink: {
|
||||
pattern: 'https://github.com/YunYouJun/valaxy/edit/main/docs/:path',
|
||||
text: 'Edit this page on GitHub',
|
||||
},
|
||||
|
||||
socialLinks: [
|
||||
|
|
|
@ -2,3 +2,6 @@ valaxy_theme_press: Valaxy Theme Press
|
|||
|
||||
theme:
|
||||
outlineTitle: On this page
|
||||
|
||||
tooltip:
|
||||
edit_this_page: Edit this page
|
||||
|
|
|
@ -2,3 +2,6 @@ valaxy_theme_press: Valaxy 主题 Press
|
|||
|
||||
theme:
|
||||
outlineTitle: 本页
|
||||
|
||||
tooltip:
|
||||
edit_this_page: 编辑本页
|
||||
|
|
|
@ -49,8 +49,6 @@ export namespace PressTheme {
|
|||
footer: Footer
|
||||
|
||||
socialLinks: SocialLink[]
|
||||
|
||||
lastUpdatedText?: string
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,3 +107,6 @@ time:
|
|||
hour: 1 Hour | {count} Hours
|
||||
minute: 1 Minute | {count} Minutes
|
||||
second: 1 Second | {count} Seconds
|
||||
|
||||
tooltip:
|
||||
last_updated: Last updated
|
||||
|
|
|
@ -106,3 +106,6 @@ time:
|
|||
hour: 1 小时 | {count} 小时
|
||||
minute: 1 分 | {count} 分
|
||||
second: 1 秒 | {count} 秒
|
||||
|
||||
tooltip:
|
||||
last_updated: 最后更新于
|
||||
|
|
|
@ -18,6 +18,8 @@ const clientDeps = [
|
|||
'@vueuse/integrations/useFuse',
|
||||
'body-scroll-lock',
|
||||
|
||||
'defu',
|
||||
|
||||
'dayjs',
|
||||
'dayjs/locale/zh-cn',
|
||||
'dayjs/plugin/relativeTime',
|
||||
|
|
|
@ -51,6 +51,7 @@ function generateStyles(roots: string[], options: ResolvedValaxyOptions) {
|
|||
|
||||
function generateLocales(roots: string[]) {
|
||||
const imports: string[] = [
|
||||
'import { defu } from "defu"',
|
||||
'const messages = { "zh-CN": {}, en: {} }',
|
||||
]
|
||||
const languages = ['zh-CN', 'en']
|
||||
|
@ -61,7 +62,8 @@ function generateLocales(roots: string[]) {
|
|||
if (fs.existsSync(langYml) && fs.readFileSync(langYml, 'utf-8')) {
|
||||
const varName = lang.replace('-', '') + i
|
||||
imports.unshift(`import ${varName} from "${toAtFS(langYml)}"`)
|
||||
imports.push(`Object.assign(messages['${lang}'], ${varName})`)
|
||||
// pre override next
|
||||
imports.push(`messages['${lang}'] = defu(${varName}, messages['${lang}'])`)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
"cross-spawn": "^7.0.3",
|
||||
"css-i18n": "^0.0.2",
|
||||
"dayjs": "^1.11.10",
|
||||
"defu": "^6.1.2",
|
||||
"ejs": "^3.1.9",
|
||||
"escape-html": "^1.0.3",
|
||||
"feed": "^4.2.2",
|
||||
|
|
|
@ -253,6 +253,9 @@ importers:
|
|||
dayjs:
|
||||
specifier: ^1.11.10
|
||||
version: 1.11.10
|
||||
defu:
|
||||
specifier: ^6.1.2
|
||||
version: 6.1.2
|
||||
ejs:
|
||||
specifier: ^3.1.9
|
||||
version: 3.1.9
|
||||
|
@ -5349,7 +5352,7 @@ packages:
|
|||
/eslint-import-resolver-node@0.3.9:
|
||||
resolution: {integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==}
|
||||
dependencies:
|
||||
debug: 3.2.7(supports-color@8.1.1)
|
||||
debug: 3.2.7(supports-color@5.5.0)
|
||||
is-core-module: 2.13.0
|
||||
resolve: 1.22.4
|
||||
transitivePeerDependencies:
|
||||
|
@ -5378,7 +5381,7 @@ packages:
|
|||
optional: true
|
||||
dependencies:
|
||||
'@typescript-eslint/parser': 6.7.4(eslint@8.50.0)(typescript@5.2.2)
|
||||
debug: 3.2.7(supports-color@8.1.1)
|
||||
debug: 3.2.7(supports-color@5.5.0)
|
||||
eslint: 8.50.0
|
||||
eslint-import-resolver-node: 0.3.9
|
||||
transitivePeerDependencies:
|
||||
|
@ -5432,7 +5435,7 @@ packages:
|
|||
peerDependencies:
|
||||
eslint: ^7.2.0 || ^8
|
||||
dependencies:
|
||||
debug: 3.2.7(supports-color@8.1.1)
|
||||
debug: 3.2.7(supports-color@5.5.0)
|
||||
doctrine: 2.1.0
|
||||
eslint: 8.50.0
|
||||
eslint-import-resolver-node: 0.3.9
|
||||
|
|
|
@ -6,9 +6,10 @@ import consola from 'consola'
|
|||
import { cyan, gray, yellow } from 'kolorist'
|
||||
|
||||
export const packages = [
|
||||
'valaxy',
|
||||
'valaxy-theme-yun',
|
||||
'create-valaxy',
|
||||
'valaxy',
|
||||
'valaxy-theme-press',
|
||||
'valaxy-theme-yun',
|
||||
]
|
||||
|
||||
export const templates = [
|
||||
|
|
Loading…
Reference in New Issue