Skip to content

Commit

Permalink
docs: setup the translation helper (#2373)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinjiang authored Mar 20, 2024
1 parent 963e379 commit a99f563
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<lang>` 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 [<lang>]`: 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 <lang>`: Compare the docs with the latest checkpoint for your language.
- `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.
19 changes: 19 additions & 0 deletions docs/.vitepress/theme/index.mts
Original file line number Diff line number Diff line change
@@ -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 <code>${hash}</code>.',
}


export default {
...Theme,
Layout() {
return h(Theme.Layout, null, {
'doc-before': () => h(TranslationStatus, { status, i18nLabels }),
})
},
}
6 changes: 6 additions & 0 deletions docs/.vitepress/translation-status.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"fr": {
"hash": "1d8e1ee",
"date": "2024-02-14"
}
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"unplugin-vue-components": "0.26.0",
"vite": "5.2.0",
"vitepress": "1.0.0-rc.45",
"vitepress-translation-helper": "^0.1.3",
"vitest": "1.4.0",
"vue": "3.4.21",
"vue-class-component": "8.0.0-rc.1",
Expand All @@ -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"
},
Expand Down
44 changes: 44 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a99f563

Please sign in to comment.