From 65a61d3db57bb4cacf7150ce21cea723330ac960 Mon Sep 17 00:00:00 2001 From: Jinjiang Date: Tue, 19 Mar 2024 19:17:53 +0800 Subject: [PATCH 1/2] docs: setup the translation helper --- docs/.vitepress/theme/index.mts | 19 +++++++++++ docs/.vitepress/translation-status.json | 6 ++++ package.json | 4 +++ pnpm-lock.yaml | 44 +++++++++++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 docs/.vitepress/theme/index.mts create mode 100644 docs/.vitepress/translation-status.json diff --git a/docs/.vitepress/theme/index.mts b/docs/.vitepress/theme/index.mts new file mode 100644 index 000000000..c4dc74079 --- /dev/null +++ b/docs/.vitepress/theme/index.mts @@ -0,0 +1,19 @@ +import { h } from 'vue' +import Theme from 'vitepress/theme' +import TranslationStatus from 'vitepress-translation-helper/ui/TranslationStatus.vue' +import status from '../translation-status.json' + +const i18nLabels = { + // TODO: to be translated + fr: 'The translation is synced to the docs on ${date} of which the commit hash is ${hash}.', +} + + +export default { + ...Theme, + Layout() { + return h(Theme.Layout, null, { + 'doc-before': () => h(TranslationStatus, { status, i18nLabels }), + }) + }, +} diff --git a/docs/.vitepress/translation-status.json b/docs/.vitepress/translation-status.json new file mode 100644 index 000000000..132c8c5eb --- /dev/null +++ b/docs/.vitepress/translation-status.json @@ -0,0 +1,6 @@ +{ + "fr": { + "hash": "1d8e1ee", + "date": "2024-02-14" + } +} \ No newline at end of file diff --git a/package.json b/package.json index 9a7faf585..5d15237ef 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "unplugin-vue-components": "0.26.0", "vite": "5.1.6", "vitepress": "1.0.0-rc.45", + "vitepress-translation-helper": "^0.1.3", "vitest": "1.3.1", "vue": "3.4.21", "vue-class-component": "8.0.0-rc.1", @@ -81,6 +82,9 @@ "lint:fix": "pnpm run lint --fix", "docs:dev": "vitepress dev docs", "docs:build": "vitepress build docs", + "docs:translation:compare": "v-translation compare --status-file=docs/.vitepress/translation-status.json", + "docs:translation:update": "v-translation update --status-file=docs/.vitepress/translation-status.json", + "docs:translation:status": "v-translation status --status-file=docs/.vitepress/translation-status.json", "vue-tsc": "vue-tsc --noEmit -p tsconfig.volar.json", "prepublishOnly": "pnpm run build" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 300da9ae5..cb2f2653a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -106,6 +106,9 @@ devDependencies: vitepress: specifier: 1.0.0-rc.45 version: 1.0.0-rc.45(@types/node@20.11.27)(search-insights@2.7.0)(typescript@5.4.2) + vitepress-translation-helper: + specifier: ^0.1.3 + version: 0.1.3(vitepress@1.0.0-rc.45)(vue@3.4.21) vitest: specifier: 1.3.1 version: 1.3.1(@types/node@20.11.27)(jsdom@24.0.0) @@ -987,6 +990,18 @@ packages: '@jridgewell/sourcemap-codec': 1.4.14 dev: true + /@kwsites/file-exists@1.1.1: + resolution: {integrity: sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==} + dependencies: + debug: 4.3.4 + transitivePeerDependencies: + - supports-color + dev: true + + /@kwsites/promise-deferred@1.1.1: + resolution: {integrity: sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==} + dev: true + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -3096,6 +3111,10 @@ packages: brace-expansion: 2.0.1 dev: true + /minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + dev: true + /minisearch@6.3.0: resolution: {integrity: sha512-ihFnidEeU8iXzcVHy74dhkxh/dn8Dc08ERl0xwoMMGqp4+LvRSCgicb+zGqWthVokQKvCSxITlh3P08OzdTYCQ==} dev: true @@ -3511,6 +3530,16 @@ packages: engines: {node: '>=14'} dev: true + /simple-git@3.23.0: + resolution: {integrity: sha512-P9ggTW8vb/21CAL/AmnACAhqBDfnqSSZVpV7WuFtsFR9HLunf5IqQvk+OXAQTfkcZep8pKnt3DV3o7w3TegEkQ==} + dependencies: + '@kwsites/file-exists': 1.1.1 + '@kwsites/promise-deferred': 1.1.1 + debug: 4.3.4 + transitivePeerDependencies: + - supports-color + dev: true + /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -3876,6 +3905,21 @@ packages: fsevents: 2.3.3 dev: true + /vitepress-translation-helper@0.1.3(vitepress@1.0.0-rc.45)(vue@3.4.21): + resolution: {integrity: sha512-KandbALKgfKmRwYBX1Wt/A/38fhACmK+962S3hYgdvzSgwM2EOO5XgEUxPKXEil5kR1eNZKJJIPbQp52h8kCpA==} + hasBin: true + peerDependencies: + vitepress: 1.0.0-rc.36 + vue: ^3.4.8 + dependencies: + minimist: 1.2.8 + simple-git: 3.23.0 + vitepress: 1.0.0-rc.45(@types/node@20.11.27)(search-insights@2.7.0)(typescript@5.4.2) + vue: 3.4.21(typescript@5.4.2) + transitivePeerDependencies: + - supports-color + dev: true + /vitepress@1.0.0-rc.45(@types/node@20.11.27)(search-insights@2.7.0)(typescript@5.4.2): resolution: {integrity: sha512-/OiYsu5UKpQKA2c0BAZkfyywjfauDjvXyv6Mo4Ra57m5n4Bxg1HgUGoth1CLH2vwUbR/BHvDA9zOM0RDvgeSVQ==} hasBin: true From afd589881b2d91639acfb6139e82895ed2796433 Mon Sep 17 00:00:00 2001 From: Jinjiang Date: Wed, 20 Mar 2024 21:08:50 +0800 Subject: [PATCH 2/2] chore: add contributing docs guide --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 4be440de2..53ca3cabb 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,20 @@ See the [docs](https://test-utils.vuejs.org/). ## Development Get started by running `pnpm install`. You can run the tests with `pnpm test`. That's it! + +## Contributing Docs + +All the documentation files can be found in `packages/docs`. It contains the English markdown files while translation(s) are stored in their corresponding `` sub-folder(s): + +- [`fr`](https://github.com/vuejs/test-utils/tree/main/packages/docs/fr): French translation. + +Besides that, the `.vitepress` sub-folder contains the config and theme, including the i18n information. + +- `pnpm docs:dev`: Start the docs dev server. +- `pnpm docs:build`: Build the docs. + +To add or maintain the translations, we follow the [Vue Ecosystem Translation Guidelines](https://github.com/vuejs-translations/guidelines/blob/main/README_ECOSYSTEM.md). + +- `pnpm docs:translation:status []`: Show the translation status for your language. If you don't specify a language, it will show the status for all languages. +- `pnpm docs:translation:compare `: Compare the docs with the latest checkpoint for your language. +- `pnpm docs:translation:update []`: Update the checkpoint for your language. The checkpoint will be set by the latest commit hash. However, you can also specify a commit hash manually.