Skip to content

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamOfIce committed Apr 28, 2023
1 parent e7b7e0e commit d8e32d4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 32 deletions.
43 changes: 26 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ I18n plugin for [VuePress v2](https://github.com/vuepress/vuepress-next)
## Features

- [x] Fill non-existent pages in translation directories
- [x] Translation obsolescence alert (based on git data)
- [ ] HMR support
- [x] Translation obsolescence alert (based on git or file info)
- [x] HMR support
- [ ] Development guide

## Usage
Expand Down Expand Up @@ -48,42 +48,51 @@ export default defineUserConfig({
```ts
interface I18nPluginOptions {
/**
* Calculate updatedTime when not exist
* @note may significantly slow down dev server startup
* @default app.env.isBuild || app.env.isDebug
* Path prefix for source language version
* @default "/"
*/
calcUpdatedTime: boolean;
baseLocalePath?: string;
/**
* Page filter
* @param page VuePress page object
* @returns Whether the page should be included
*/
filter?: (page: Page) => boolean;
/**
* Link to translation guide(in default locale)
*/
translationGuide?: string;
/**
* Custom locales for i18n plugin
*/
locales?: Record<string, Partial<I18nPluginLocaleData>>;
/**
* Path prefix for source language version
* @default "/"
* Add tag `untranslated` or `outdated` to page
* need to load before [vuepress-plugin-blog2]{@link https://www.npmjs.com/package/vuepress-plugin-blog2}
* @default false
*/
baseLocalePath?: string;
tag?: boolean;
/**
* Tip container options
* @see I18nPluginTipOptions
* @default true
*/
tip?: I18nPluginTipOptions | boolean;
/**
* Add tag `untranslated` or `outdated` to page
* need to load before [vuepress-plugin-blog2]{@link https://www.npmjs.com/package/vuepress-plugin-blog2}
* @default false
* Link to translation guide(in default locale)
*/
tag?: boolean;
translationGuide?: string;
/**
* Calculate updatedTime when not exist
* - `git`: read updated time from git
* - `file`: read updated time from file info
* - a function:
* @param page VuePress page object
* @param app VuePress app
* @returns a mode name or a timestamp
* @note git mode may significantly slow down dev server startup
* @default (_page, app) => app.env.isBuild || app.env.isDebug ? "git" : undefined
*/
updatedTime?:
| "git"
| "file"
| ((page: Page, app: App) => number | undefined | "git" | "file");
}

interface I18nPluginTipOptions {
Expand Down
41 changes: 28 additions & 13 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
## 功能

- [x] 填充翻译目录下不存在的页面
- [x] 翻译过时提示(基于 git 数据)
- [ ] HMR 支持
- [x] 过时翻译提示(支持 `git`和文件数据源)
- [c] HMR 支持
- [ ] 开发指南

## 食用方法
Expand Down Expand Up @@ -50,36 +50,51 @@ export default defineUserConfig({
```ts
interface I18nPluginOptions {
/**
* 当 UpdatedTime 不存在时进行计算
* @note 可能大幅降低开发服务器启动速度
* @default app.env.isBuild || app.env.isDebug
* 源语言版本所在的路径
* @default "/"
*/
calcUpdatedTime: boolean;
baseLocalePath?: string;
/**
* 页面过滤器, 默认包含主页外所有由 markdown 文件生成的页面
* @param page VuePress的 page 对象
* @returns 插件是否应该包含此页面
*/
filter?: (page: Page) => boolean;
/**
* 翻译指南的链接, 为空时不显示
*/
translationGuide?: string;
/**
* 自定义本地化配置, 应为一个以路径前缀为键,本地化数据为值的对象
*/
locales?: Record<string, Partial<I18nPluginLocaleData>>;
/**
* 源语言版本所在的路径
* @default "/"
* 向页面添加 tag `untranslated` 或 `outdated`
* 需在 [vuepress-plugin-blog2]{@link https://www.npmjs.com/package/vuepress-plugin-blog2} 前加载
* @default false
*/
baseLocalePath?: string;
tag?: boolean;
/**
* 提示功能配置, false 表示禁用
* @see I18nPluginTipOptions
* @default true
*/
tip?: I18nPluginTipOptions | boolean;
/**
* 翻译指南的链接, 为空时不显示
*/
translationGuide?: string;
/**
* 当 UpdatedTime 不存在时进行计算
* - `git`: 从 git 历史读取更新时间
* - `file`: 从文件信息读取更新时间
* - 一个函数:
* @param page VuePress page 对象
* @param app VuePress app
* @returns 一个模式名或时间戳
* @note git 模式可能大幅降低开发服务器启动速度
* @default (_page, app) => app.env.isBuild || app.env.isDebug ? "git" : undefined
*/
updatedTime:
| "git"
| "file"
| ((page: Page, app: App) => number | undefined | "git" | "file");
}

interface I18nPluginTipOptions {
Expand Down
3 changes: 2 additions & 1 deletion src/node/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ interface I18nPluginInternalOptions {
* - a function:
* @param page VuePress page object
* @param app VuePress app
* @note may significantly slow down dev server startup
* @returns a mode name or a timestamp
* @note git mode may significantly slow down dev server startup
* @default (_page, app) => app.env.isBuild || app.env.isDebug ? "git" : undefined
*/
updatedTime:
Expand Down
1 change: 0 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default defineConfig({
},
},
plugins: [
//@ts-expect-error 2433 unknown reason
vue(),
dts({
rollupTypes: true,
Expand Down

0 comments on commit d8e32d4

Please sign in to comment.