Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: setup the translation helper #2373

Merged
merged 3 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.