Skip to content

Commit a99f563

Browse files
authored
docs: setup the translation helper (#2373)
1 parent 963e379 commit a99f563

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,20 @@ See the [docs](https://test-utils.vuejs.org/).
2424
## Development
2525

2626
Get started by running `pnpm install`. You can run the tests with `pnpm test`. That's it!
27+
28+
## Contributing Docs
29+
30+
All the documentation files can be found in `packages/docs`. It contains the English markdown files while translation(s) are stored in their corresponding `<lang>` sub-folder(s):
31+
32+
- [`fr`](https://github.com/vuejs/test-utils/tree/main/packages/docs/fr): French translation.
33+
34+
Besides that, the `.vitepress` sub-folder contains the config and theme, including the i18n information.
35+
36+
- `pnpm docs:dev`: Start the docs dev server.
37+
- `pnpm docs:build`: Build the docs.
38+
39+
To add or maintain the translations, we follow the [Vue Ecosystem Translation Guidelines](https://github.com/vuejs-translations/guidelines/blob/main/README_ECOSYSTEM.md).
40+
41+
- `pnpm docs:translation:status [<lang>]`: Show the translation status for your language. If you don't specify a language, it will show the status for all languages.
42+
- `pnpm docs:translation:compare <lang>`: Compare the docs with the latest checkpoint for your language.
43+
- `pnpm docs:translation:update <lang> [<commit>]`: 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.

docs/.vitepress/theme/index.mts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { h } from 'vue'
2+
import Theme from 'vitepress/theme'
3+
import TranslationStatus from 'vitepress-translation-helper/ui/TranslationStatus.vue'
4+
import status from '../translation-status.json'
5+
6+
const i18nLabels = {
7+
// TODO: to be translated
8+
fr: 'The translation is synced to the docs on ${date} of which the commit hash is <code>${hash}</code>.',
9+
}
10+
11+
12+
export default {
13+
...Theme,
14+
Layout() {
15+
return h(Theme.Layout, null, {
16+
'doc-before': () => h(TranslationStatus, { status, i18nLabels }),
17+
})
18+
},
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"fr": {
3+
"hash": "1d8e1ee",
4+
"date": "2024-02-14"
5+
}
6+
}

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"unplugin-vue-components": "0.26.0",
5959
"vite": "5.2.0",
6060
"vitepress": "1.0.0-rc.45",
61+
"vitepress-translation-helper": "^0.1.3",
6162
"vitest": "1.4.0",
6263
"vue": "3.4.21",
6364
"vue-class-component": "8.0.0-rc.1",
@@ -81,6 +82,9 @@
8182
"lint:fix": "pnpm run lint --fix",
8283
"docs:dev": "vitepress dev docs",
8384
"docs:build": "vitepress build docs",
85+
"docs:translation:compare": "v-translation compare --status-file=docs/.vitepress/translation-status.json",
86+
"docs:translation:update": "v-translation update --status-file=docs/.vitepress/translation-status.json",
87+
"docs:translation:status": "v-translation status --status-file=docs/.vitepress/translation-status.json",
8488
"vue-tsc": "vue-tsc --noEmit -p tsconfig.volar.json",
8589
"prepublishOnly": "pnpm run build"
8690
},

pnpm-lock.yaml

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)