Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vuejs-translations/vitepress-translation-helper
A translation toolkit for VitePress, made by vuejs-translations.
https://github.com/vuejs-translations/vitepress-translation-helper
Last synced: 5 days ago
JSON representation
A translation toolkit for VitePress, made by vuejs-translations.
- Host: GitHub
- URL: https://github.com/vuejs-translations/vitepress-translation-helper
- Owner: vuejs-translations
- License: mit
- Created: 2024-01-11T08:13:01.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-22T00:11:22.000Z (8 months ago)
- Last Synced: 2024-09-26T08:19:23.129Z (about 2 months ago)
- Language: TypeScript
- Size: 36.1 KB
- Stars: 6
- Watchers: 8
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VitePress Translation Helper
A translation toolkit for VitePress, made by vuejs-translations.
## Usage
### 1. CLI commands
```bash
Usage:
v-translation status [] [--status-file=]
v-translation compare [] [--status-file=] [--path=]
v-translation update [] [--status-file=]
v-translation --help
v-translation --versionArguments:
locale: The target locale to check/compare/update.
commit: The target commit to compare/update. It could be a branch, a tag, or a hash. Default to 'main'.Options:
-s,
--status-file:
The path to the translation status file. Default to './.vitepress/translation-status.json'.
-p,
--path:
The target files/directories to compare. You can set multiple paths if you like. Default to the whole repository.
-h,
--help:
Print this help message.
-v,
--version:
Print the version number.Examples:
v-translation status
v-translation status zh
v-translation compare zh
v-translation compare zh main
v-translation compare zh 1cf14f8
v-translation compare zh --path=docs
v-translation compare zh main --path=docs/guide --path=docs/api
v-translation update zh
v-translation update zh main
v-translation update zh 1cf14f8
```### 2. Translation Status UI
Put the translation status UI component into your VitePress theme.
```ts
import { h } from 'vue'
import { Theme, useData } from 'vitepress'
import DefaultTheme from 'vitepress/theme'// Import the Translation Status UI component.
import TranslationStatus from 'vitepress-translation-helper/ui/TranslationStatus.vue'
// This is the translation status file generated by `v-translation update`.
import status from '../translation-status.json'// Optional: custom i18n labels for your locales
const i18nLabels = {
localeA: 'xxx ${date} xxx ${hash} xxx',
localeB: 'xxx ${date} xxx ${hash} xxx',
// ...
}const theme: Theme = {
...DefaultTheme,
Layout() {
return h(DefaultTheme.Layout, null, {
// Put the Translation Status UI component into the layout.
'doc-before': () => h(TranslationStatus, { status, i18nLabels }),
})
},
}export default theme
```The default i18n label is:
```ts
'The translation is synced to the docs on ${date} of which the commit hash is${hash}
.'
```