From a4daebc1c09dd68142c2bfe48d7ca4161e5299f1 Mon Sep 17 00:00:00 2001 From: Maiko Sinkyaet Tan Date: Wed, 14 Aug 2024 20:25:29 +0800 Subject: [PATCH] refa: migrate schema text to i18n files (#244) * refa: migrate base schema text to i18n files * refa: migrate danbooru schema to i18n * refa: migrate e621 schema to i18n * refa: migrate gelbooru schema to i18n * refa: migrate konachan schema to i18n * refa: migrate local schema to i18n * refa: migrate lolibooru schema to i18n * refa: migrate lolicon schema to i18n * refa: migrate moehu schema to i18n * refa: migrate pixiv schema to i18n * refa: migrate safebooru schema to i18n * refa: migrate sankakucomplex schema to i18n * refa: migrate yandere schema to i18n * fix: format --- crowdin.yml | 4 + packages/core/src/index.ts | 70 ++++++---------- packages/core/src/locales/zh-CN.schema.yml | 41 +++++++++ .../core/src/locales/zh-CN.source.schema.yml | 7 ++ packages/core/src/source.ts | 17 ++-- packages/danbooru/src/index.ts | 16 ++-- .../danbooru/src/locales/zh-CN.schema.yml | 7 ++ packages/e621/src/index.ts | 18 ++-- packages/e621/src/locales/zh-CN.schema.yml | 8 ++ packages/gelbooru/src/index.ts | 12 ++- .../gelbooru/src/locales/zh-CN.schema.yml | 4 + packages/konachan/src/index.ts | 21 ++--- .../konachan/src/locales/zh-CN.schema.yml | 11 +++ packages/local/src/index.ts | 28 ++++--- packages/local/src/locales/zh-CN.schema.yml | 11 +++ packages/lolibooru/src/index.ts | 14 ++-- .../lolibooru/src/locales/zh-CN.schema.yml | 7 ++ packages/lolicon/src/index.ts | 4 +- packages/lolicon/src/locales/zh-CN.schema.yml | 22 +++++ packages/moehu/src/index.ts | 6 +- packages/moehu/src/locales/zh-CN.schema.yml | 2 + packages/pixiv/src/index.ts | 84 ++++++++----------- packages/pixiv/src/locales/zh-CN.schema.yml | 32 +++++++ packages/safebooru/src/index.ts | 6 +- .../safebooru/src/locales/zh-CN.schema.yml | 2 + packages/sankaku/src/index.ts | 18 ++-- packages/sankaku/src/locales/zh-CN.schema.yml | 9 ++ packages/yande/src/index.ts | 14 ++-- packages/yande/src/locales/zh-CN.schema.yml | 7 ++ 29 files changed, 321 insertions(+), 181 deletions(-) create mode 100644 packages/core/src/locales/zh-CN.schema.yml create mode 100644 packages/core/src/locales/zh-CN.source.schema.yml create mode 100644 packages/danbooru/src/locales/zh-CN.schema.yml create mode 100644 packages/e621/src/locales/zh-CN.schema.yml create mode 100644 packages/gelbooru/src/locales/zh-CN.schema.yml create mode 100644 packages/konachan/src/locales/zh-CN.schema.yml create mode 100644 packages/local/src/locales/zh-CN.schema.yml create mode 100644 packages/lolibooru/src/locales/zh-CN.schema.yml create mode 100644 packages/lolicon/src/locales/zh-CN.schema.yml create mode 100644 packages/moehu/src/locales/zh-CN.schema.yml create mode 100644 packages/pixiv/src/locales/zh-CN.schema.yml create mode 100644 packages/safebooru/src/locales/zh-CN.schema.yml create mode 100644 packages/sankaku/src/locales/zh-CN.schema.yml create mode 100644 packages/yande/src/locales/zh-CN.schema.yml diff --git a/crowdin.yml b/crowdin.yml index 66141ba7d..1fffb5e01 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -5,6 +5,10 @@ pull_request_labels: files: - source: /packages/*/src/locales/zh-CN.yml translation: /%original_path%/%locale%.yml + - source: /packages/*/src/locales/zh-CN.schema.yml + translation: /%original_path%/%locale%.schema.yml + - source: /packages/*/src/locales/zh-CN.source.schema.yml + translation: /%original_path%/%locale%.source.schema.yml - source: /docs/zh-CN/**/*.md translation: /docs/%locale%/**/%file_name%.md - source: /docs/**/zh-CN.json diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 8dfd50ff1..e3bef56f5 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -214,63 +214,47 @@ export const Config = Schema.intersect([ Schema.intersect([ Schema.union([ Schema.object({ - detectLanguage: Schema.boolean().default(false).description('自动检测输入语言并选择语言匹配的图源。'), + detectLanguage: Schema.boolean().default(false), }), Schema.object({ - detectLanguage: Schema.const(true).description('自动检测输入语言并选择语言匹配的图源。'), - confidence: Schema.number().default(0.5).description('语言检测的置信度。'), + detectLanguage: Schema.const(true), + confidence: Schema.number().default(0.5), }), ]), Schema.object({ - maxCount: Schema.number().default(10).description('每次搜索的最大数量。'), - nsfw: Schema.boolean().default(false).description('是否允许输出 NSFW 内容。'), + maxCount: Schema.number().default(10), + nsfw: Schema.boolean().default(false), }), - ]).description('搜索设置'), + ]), Schema.object({ - output: Schema.union([ - Schema.const(0).description('仅发送图片'), - Schema.const(1).description('发送图片和相关信息'), - Schema.const(2).description('发送图片、相关信息和链接'), - Schema.const(3).description('发送全部信息'), - ]) - .description('输出方式。') - .default(1), + output: Schema.union([Schema.const(0), Schema.const(1), Schema.const(2), Schema.const(3)]).default(1), outputMethod: Schema.union([ - Schema.const('one-by-one').description('逐条发送每张图片'), - Schema.const('merge-multiple').description('合并多条发送 (部分平台可能不支持)'), - Schema.const('forward-all').description('合并为子话题发送所有图片 (部分平台需求较高权限)'), - Schema.const('forward-multiple').description('仅当多于一张图片使用合并为子话题发送 (部分平台需求较高权限)'), + Schema.const('one-by-one'), + Schema.const('merge-multiple'), + Schema.const('forward-all'), + Schema.const('forward-multiple'), ]) .experimental() .role('radio') - .default('merge-multiple') - .description('发送方式。'), + .default('merge-multiple'), preferSize: Schema.union([ - Schema.const('original').description('原始尺寸'), - Schema.const('large').description('较大尺寸 (通常为约 1200px)'), - Schema.const('medium').description('中等尺寸 (通常为约 600px)'), - Schema.const('small').description('较小尺寸 (通常为约 300px)'), - Schema.const('thumbnail').description('缩略图'), - ]) - .description('优先使用图片的最大尺寸。') - .default('large'), - autoResize: Schema.computed(Schema.boolean()) - .experimental() - .default(false) - .description('根据 preferSize 自动缩小过大的图片。
- 需要安装提供 canvas 服务的插件'), - asset: Schema.boolean().default(false).description('优先使用 [assets服务](https://assets.koishi.chat/) 转存图片。'), - base64: Schema.boolean().default(false).description('使用 base64 发送图片。'), - spoiler: Schema.union([ - Schema.const(0).description('禁用'), - Schema.const(1).description('所有图片'), - Schema.const(2).description('仅 NSFW 图片'), - ]) - .description('发送为隐藏图片,单击后显示(在 QQ 平台中以「合并转发」发送)。') + Schema.const('original'), + Schema.const('large'), + Schema.const('medium'), + Schema.const('small'), + Schema.const('thumbnail'), + ]).default('large'), + autoResize: Schema.computed(Schema.boolean()).experimental().default(false), + asset: Schema.boolean().default(false), + base64: Schema.boolean().default(false), + spoiler: Schema.union([Schema.const(0), Schema.const(1), Schema.const(2)]) .default(0) .experimental(), - showTips: Schema.boolean().default(true).description('是否输出使用提示信息。'), - }).description('输出设置'), -]) + showTips: Schema.boolean().default(true), + }), +]).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), +}) export function apply(ctx: Context, config: Config) { // @ts-expect-error inject structure not compatible diff --git a/packages/core/src/locales/zh-CN.schema.yml b/packages/core/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..20e27e165 --- /dev/null +++ b/packages/core/src/locales/zh-CN.schema.yml @@ -0,0 +1,41 @@ +$inner: + - $description: 搜索设置 + detectLanguage: 自动检测输入语言并选择语言匹配的图源。 + confidence: 语言检测的置信度。 + maxCount: 每次搜索的最大数量。 + nsfw: 是否允许输出 NSFW 内容。 + + - $description: 输出设置 + output: + $description: 输出方式。 + $inner: + - 仅发送图片 + - 发送图片和相关信息 + - 发送图片、相关信息和链接 + - 发送全部信息 + outputMethod: + $description: 发送方式。 + $inner: + - 逐条发送每张图片 + - 合并多条发送 (部分平台可能不支持) + - 合并为子话题发送所有图片 (部分平台需求较高权限) + - 仅当多于一张图片使用合并为子话题发送 (部分平台需求较高权限) + preferSize: + $description: 优先使用图片的最大尺寸。 + $inner: + - 原始尺寸 + - 较大尺寸 (通常为约 1200px) + - 中等尺寸 (通常为约 600px) + - 较小尺寸 (通常为约 300px) + - 缩略图 + autoResize: + $description: 根据 preferSize 自动缩小过大的图片。 **需要安装提供 canvas 服务的插件** + asset: 优先使用 [assets服务](https://assets.koishi.chat/) 转存图片。 + base64: 使用 base64 发送图片。 + spoiler: + $description: 发送为隐藏图片,单击后显示(在 QQ 平台中以「合并转发」发送)。 + $inner: + - 禁用 + - 所有图片 + - 仅 NSFW 图片 + showTips: 是否输出使用提示信息。 diff --git a/packages/core/src/locales/zh-CN.source.schema.yml b/packages/core/src/locales/zh-CN.source.schema.yml new file mode 100644 index 000000000..6068d4d86 --- /dev/null +++ b/packages/core/src/locales/zh-CN.source.schema.yml @@ -0,0 +1,7 @@ +$inner: + - $description: 全局设置 + label: 图源标签,可用于在指令中手动指定图源。 + weight: 图源权重。在多个符合标签的图源中,将按照各自的权重随机选择。 + + - $description: 请求设置 + proxyAgent: 请求图片时使用代理服务器。 diff --git a/packages/core/src/source.ts b/packages/core/src/source.ts index 9f622ccc1..132f5f18b 100644 --- a/packages/core/src/source.ts +++ b/packages/core/src/source.ts @@ -45,16 +45,15 @@ export namespace ImageSource { export function createSchema(o: { label: string }) { return Schema.intersect([ Schema.object({ - label: Schema.string().default(o.label).description('图源标签,可用于在指令中手动指定图源。'), - weight: Schema.number() - .min(1) - .default(1) - .description('图源权重。在多个符合标签的图源中,将按照各自的权重随机选择。'), - }).description('全局设置'), + label: Schema.string().default(o.label), + weight: Schema.number().min(1).default(1), + }), Schema.object({ - proxyAgent: Schema.string().default(undefined).description('请求图片时使用代理服务器。'), - }).description('请求设置'), - ]) + proxyAgent: Schema.string().default(undefined), + }), + ]).i18n({ + 'zh-CN': require('./locales/zh-CN.source.schema.yml'), + }) } export const Config: Schema = createSchema({ label: 'default' }) diff --git a/packages/danbooru/src/index.ts b/packages/danbooru/src/index.ts index 214beee34..54165bb1a 100644 --- a/packages/danbooru/src/index.ts +++ b/packages/danbooru/src/index.ts @@ -53,21 +53,19 @@ namespace DanbooruImageSource { export const Config: Schema = Schema.intersect([ ImageSource.createSchema({ label: 'danbooru' }), Schema.object({ - endpoint: Schema.string().description('Danbooru 的 URL。').default('https://danbooru.donmai.us/'), + endpoint: Schema.string().default('https://danbooru.donmai.us/'), /** * @see https://danbooru.donmai.us/wiki_pages/help%3Aapi */ keyPairs: Schema.array( Schema.object({ - login: Schema.string().required().description('用户名。'), - apiKey: Schema.string().required().role('secret').description('API 密钥。'), + login: Schema.string().required(), + apiKey: Schema.string().required().role('secret'), }), - ) - .default([]) - .description( - 'Danbooru 的登录凭据。[点击前往获取及设置教程](https://booru.koishi.chat/zh-CN/plugins/danbooru.html#configure-credentials)', - ), - }).description('搜索设置'), + ).default([]), + }).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/danbooru/src/locales/zh-CN.schema.yml b/packages/danbooru/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..7cdfb5d31 --- /dev/null +++ b/packages/danbooru/src/locales/zh-CN.schema.yml @@ -0,0 +1,7 @@ +$description: 搜索设置 +endpoint: Danbooru 的 URL。 +keyPairs: + $description: Danbooru 的登录凭据。[点击前往获取及设置教程](https://booru.koishi.chat/zh-CN/plugins/danbooru.html#configure-credentials) + $inner: + login: 用户名。 + apiKey: API 密钥。 diff --git a/packages/e621/src/index.ts b/packages/e621/src/index.ts index c39a55b7f..86c8295e3 100644 --- a/packages/e621/src/index.ts +++ b/packages/e621/src/index.ts @@ -68,22 +68,20 @@ namespace e621ImageSource { export const Config: Schema = Schema.intersect([ ImageSource.createSchema({ label: 'e621' }), Schema.object({ - endpoint: Schema.string().description('e621/e926 的 URL。').default('https://e621.net/'), + endpoint: Schema.string().default('https://e621.net/'), keyPairs: Schema.array( Schema.object({ - login: Schema.string().required().description('e621/e926 的用户名。'), - apiKey: Schema.string().required().role('secret').description('e621/e926 的 API Key。'), + login: Schema.string().required(), + apiKey: Schema.string().required().role('secret'), }), - ) - .default([]) - .description( - 'e621/e926 的登录凭据。[点击前往获取及设置教程](https://booru.koishi.chat/zh-CN/plugins/e621.html#configure-credentials)', - ), - userAgent: Schema.string().description('设置请求的 User Agent。').default( + ).default([]), + userAgent: Schema.string().default( // eslint-disable-next-line max-len 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.37', ), - }).description('搜索设置'), + }).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/e621/src/locales/zh-CN.schema.yml b/packages/e621/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..33c2d7bbd --- /dev/null +++ b/packages/e621/src/locales/zh-CN.schema.yml @@ -0,0 +1,8 @@ +$description: 搜索设置 +endpoint: e621/e926 的 URL。 +keyPairs: + $description: e621/e926 的登录凭据。[点击前往获取及设置教程](https://booru.koishi.chat/zh-CN/plugins/e621.html#configure-credentials) + $inner: + login: e621/e926 的用户名。 + apiKey: e621/e926 的 API Key。 +userAgent: 设置请求的 User Agent。 diff --git a/packages/gelbooru/src/index.ts b/packages/gelbooru/src/index.ts index 465dd1b3d..07bb1d8ac 100644 --- a/packages/gelbooru/src/index.ts +++ b/packages/gelbooru/src/index.ts @@ -67,13 +67,11 @@ namespace GelbooruImageSource { export const Config: Schema = Schema.intersect([ ImageSource.createSchema({ label: 'gelbooru' }), Schema.object({ - endpoint: Schema.string().description('Gelbooru 的 URL。').default('https://gelbooru.com/index.php'), - keyPairs: Schema.array(Schema.string().required().role('secret')) - .description( - 'Gelbooru 的登录凭据。[点击前往获取及设置教程](https://booru.koishi.chat/zh-CN/plugins/gelbooru.html#configure-credentials)', - ) - .default([]), - }).description('搜索设置'), + endpoint: Schema.string().default('https://gelbooru.com/index.php'), + keyPairs: Schema.array(Schema.string().required().role('secret')).default([]), + }).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/gelbooru/src/locales/zh-CN.schema.yml b/packages/gelbooru/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..fd6b0a002 --- /dev/null +++ b/packages/gelbooru/src/locales/zh-CN.schema.yml @@ -0,0 +1,4 @@ +$description: 搜索设置 +endpoint: Gelbooru 的 URL。 +keyPairs: + $description: Gelbooru 的登录凭据。[点击前往获取及设置教程](https://booru.koishi.chat/zh-CN/plugins/gelbooru.html#configure-credentials) diff --git a/packages/konachan/src/index.ts b/packages/konachan/src/index.ts index ca038ce86..99fb224dd 100644 --- a/packages/konachan/src/index.ts +++ b/packages/konachan/src/index.ts @@ -75,21 +75,18 @@ namespace KonachanImageSource { export const Config: Schema = Schema.intersect([ ImageSource.createSchema({ label: 'konachan' }), Schema.object({ - endpoint: Schema.union([ - Schema.const('https://konachan.com/').description('Konachan.com (NSFW)'), - Schema.const('https://konachan.net/').description('Konachan.net (SFW)'), - ]) - .description('Konachan 的 URL。') - .default('https://konachan.com/'), + endpoint: Schema.union([Schema.const('https://konachan.com/'), Schema.const('https://konachan.net/')]).default( + 'https://konachan.com/', + ), keyPairs: Schema.array( Schema.object({ - login: Schema.string().required().description('用户名'), - password: Schema.string().required().role('secret').description('密码'), + login: Schema.string().required(), + password: Schema.string().required().role('secret'), }), - ) - .default([]) - .description('Konachan 的登录凭据。'), - }).description('搜索设置'), + ).default([]), + }).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/konachan/src/locales/zh-CN.schema.yml b/packages/konachan/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..2da310004 --- /dev/null +++ b/packages/konachan/src/locales/zh-CN.schema.yml @@ -0,0 +1,11 @@ +$description: 搜索设置 +endpoint: + $description: Konachan 的 URL。 + $inner: + - Konachan.com (NSFW) + - Konachan.net (SFW) +keyPairs: + $description: Konachan 的登录凭据。 + $inner: + login: 用户名 + password: 密码 diff --git a/packages/local/src/index.ts b/packages/local/src/index.ts index f13068f55..36c0bac6f 100644 --- a/packages/local/src/index.ts +++ b/packages/local/src/index.ts @@ -184,19 +184,21 @@ namespace LocalImageSource { export const Config: Schema = Schema.intersect([ ImageSource.createSchema({ label: 'local' }), - Schema.object({ - // TODO: Schema.path()? - endpoint: Schema.array(String).description('图源文件夹,支持多个不同的文件夹'), - storage: Schema.union(['file', 'database']).description('图源数据保存方式').default('file'), - reload: Schema.boolean().description('每次启动时重新构建图源数据').default(false), - languages: Schema.array(String).description('支持的语言').default(['zh-CN']), - }).description('图源设置'), - Schema.object({ - scraper: Schema.string() - .description('文件名元信息生成格式,详见文档') - .default('{filename}-{tag}'), - extension: Schema.array(String).description('支持的扩展名').default(['.jpg', '.png', '.jpeg', '.gif']), - }).description('文件设置'), + Schema.intersect([ + Schema.object({ + // TODO: Schema.path()? + endpoint: Schema.array(String), + storage: Schema.union(['file', 'database']).default('file'), + reload: Schema.boolean().default(false), + languages: Schema.array(String).default(['zh-CN']), + }), + Schema.object({ + scraper: Schema.string().default('{filename}-{tag}'), + extension: Schema.array(String).default(['.jpg', '.png', '.jpeg', '.gif']), + }), + ]).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/local/src/locales/zh-CN.schema.yml b/packages/local/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..3d9dc6bea --- /dev/null +++ b/packages/local/src/locales/zh-CN.schema.yml @@ -0,0 +1,11 @@ +$inner: + - $description: 图源设置 + $inner: + endpoint: 图源文件夹,支持多个不同的文件夹 + storage: 图源数据保存方式 + reload: 每次启动时重新构建图源数据 + languages: 支持的语言 + - $description: 文件设置 + $inner: + scraper: 文件名元信息生成格式,详见文档 + extension: 支持的扩展名 diff --git a/packages/lolibooru/src/index.ts b/packages/lolibooru/src/index.ts index eb4294a9b..da3d07de8 100644 --- a/packages/lolibooru/src/index.ts +++ b/packages/lolibooru/src/index.ts @@ -78,16 +78,16 @@ namespace LolibooruImageSource { export const Config: Schema = Schema.intersect([ ImageSource.createSchema({ label: 'lolibooru' }), Schema.object({ - endpoint: Schema.string().description('Lolibooru 的 URL。').default('https://lolibooru.moe'), + endpoint: Schema.string().default('https://lolibooru.moe'), keyPairs: Schema.array( Schema.object({ - login: Schema.string().required().description('用户名'), - password: Schema.string().required().role('secret').description('密码'), + login: Schema.string().required(), + password: Schema.string().required().role('secret'), }), - ) - .default([]) - .description('Lolibooru 的登录凭据。'), - }).description('搜索设置'), + ).default([]), + }).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/lolibooru/src/locales/zh-CN.schema.yml b/packages/lolibooru/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..14cc90fb1 --- /dev/null +++ b/packages/lolibooru/src/locales/zh-CN.schema.yml @@ -0,0 +1,7 @@ +$description: 搜索设置 +endpoint: Lolibooru 的 URL。 +keyPairs: + $description: Lolibooru 的登录凭据。 + $inner: + login: 用户名 + password: 密码 diff --git a/packages/lolicon/src/index.ts b/packages/lolicon/src/index.ts index 13a8cae53..f4a91d3b8 100644 --- a/packages/lolicon/src/index.ts +++ b/packages/lolicon/src/index.ts @@ -83,7 +83,9 @@ namespace LoliconImageSource { ]) .description('是否排除 AI 作品。') .default(true), - }).description('搜索设置'), + }).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/lolicon/src/locales/zh-CN.schema.yml b/packages/lolicon/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..515282784 --- /dev/null +++ b/packages/lolicon/src/locales/zh-CN.schema.yml @@ -0,0 +1,22 @@ +$description: 搜索设置 +endpoint: Lolicon API 的 URL。 +r18: + $description: 是否检索 R18 图片。 + $inner: + - 非 R18 + - 仅 R18 + - 混合 +proxy: + $description: Pixiv 反代服务。 + $inner: + - i.pixiv.re + - i.pixiv.cat + - i.pixiv.nl + - $description: 自定义 + $inner: + endpoint: 反代服务的地址。 +excludeAI: + $description: 是否排除 AI 作品。 + $inner: + - 排除AI作品 + - 不排除AI作品 diff --git a/packages/moehu/src/index.ts b/packages/moehu/src/index.ts index af544588a..7cd3815e8 100644 --- a/packages/moehu/src/index.ts +++ b/packages/moehu/src/index.ts @@ -61,8 +61,10 @@ namespace MoehuImageSource { export const Config: Schema = Schema.intersect([ ImageSource.createSchema({ label: 'moehu' }), Schema.object({ - endpoint: Schema.string().description('Moehu 的 URL。').default('https://img.moehu.org/pic.php'), - }).description('搜索设置'), + endpoint: Schema.string().default('https://img.moehu.org/pic.php'), + }).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/moehu/src/locales/zh-CN.schema.yml b/packages/moehu/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..780607c61 --- /dev/null +++ b/packages/moehu/src/locales/zh-CN.schema.yml @@ -0,0 +1,2 @@ +$description: 搜索设置 +endpoint: Moehu 的 URL。 diff --git a/packages/pixiv/src/index.ts b/packages/pixiv/src/index.ts index 1359e8ffa..d54c34b88 100644 --- a/packages/pixiv/src/index.ts +++ b/packages/pixiv/src/index.ts @@ -240,62 +240,46 @@ namespace PixivImageSource { export const Config: Schema = Schema.intersect([ ImageSource.createSchema({ label: 'pixiv' }), - Schema.object({ - endpoint: Schema.string().description('Pixiv 的 API Root').default('https://app-api.pixiv.net/'), - // TODO: set token as non-required for illust recommend - token: Schema.string().required().role('secret').description('Pixiv 的 Refresh Token'), - minBookmarks: Schema.number() - .default(0) - .description('最少收藏数,仅在设置了 Token 并有 Pixiv Premium 的情况下可用'), - rank: Schema.union([ - Schema.const(0).description('全年龄'), - Schema.const(1).description('R18'), - Schema.const(2).description('R18G'), - ]) - .description('年龄分级') - .default(0), - ai: Schema.union([Schema.const(1).description('不允许AI作品'), Schema.const(2).description('允许AI作品')]) - .description('是否允许搜索AI作品') - .default(1), - }).description('搜索设置'), Schema.intersect([ Schema.object({ - bypassMethod: Schema.union([ - Schema.const('proxy').description('使用现有反代服务'), - Schema.const('route').description('使用插件本地反代'), - Schema.const('asset').description('下载到 assets 缓存'), - ]) - .description( - '突破 Pixiv 站点图片防外部引用检测的方式。[参考](https://booru.koishi.chat/zh-CN/plugins/pixiv.html#bypass-pixiv-detection)', - ) - .default('proxy'), + endpoint: Schema.string().default('https://app-api.pixiv.net/'), + // TODO: set token as non-required for illust recommend + token: Schema.string().required().role('secret'), + minBookmarks: Schema.number().default(0), + rank: Schema.union([Schema.const(0), Schema.const(1), Schema.const(2)]).default(0), + ai: Schema.union([Schema.const(1), Schema.const(2)]).default(1), }), - Schema.union([ + Schema.intersect([ Schema.object({ - bypassMethod: Schema.const('proxy'), - proxy: Schema.union([ - Schema.const('https://i.pixiv.re').description('i.pixiv.re'), - Schema.const('https://i.pixiv.cat').description('i.pixiv.cat'), - Schema.const('https://i.pixiv.nl').description('i.pixiv.nl'), - Schema.object({ - endpoint: Schema.string().required().description('反代服务的地址。'), - }).description('自定义'), - ]) - .description('Pixiv 反代服务。') - .default('https://i.pixiv.re'), - }), - Schema.object({ - bypassMethod: Schema.const('route'), - route: Schema.string() - .description('反代服务的路径(需在 server 插件配置中填写 `selfUrl`)。') - .default('/booru/pixiv/proxy'), - aesKey: Schema.string().hidden().description('AES 加密密钥').default(''), - }), - Schema.object({ - bypassMethod: Schema.const('asset'), + bypassMethod: Schema.union([Schema.const('proxy'), Schema.const('route'), Schema.const('asset')]).default( + 'proxy', + ), }), + Schema.union([ + Schema.object({ + bypassMethod: Schema.const('proxy'), + proxy: Schema.union([ + Schema.const('https://i.pixiv.re'), + Schema.const('https://i.pixiv.cat'), + Schema.const('https://i.pixiv.nl'), + Schema.object({ + endpoint: Schema.string().required(), + }), + ]).default('https://i.pixiv.re'), + }), + Schema.object({ + bypassMethod: Schema.const('route'), + route: Schema.string().default('/booru/pixiv/proxy'), + aesKey: Schema.string().hidden().default(''), + }), + Schema.object({ + bypassMethod: Schema.const('asset'), + }), + ]), ]), - ]), + ]).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/pixiv/src/locales/zh-CN.schema.yml b/packages/pixiv/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..b39338c47 --- /dev/null +++ b/packages/pixiv/src/locales/zh-CN.schema.yml @@ -0,0 +1,32 @@ +$description: 搜索设置 +$inner: + - endpoint: Pixiv 的 API Root + token: Pixiv 的 Refresh Token + minBookmarks: 最少收藏数,仅在设置了 Token 并有 Pixiv Premium 的情况下可用 + rank: + $description: 年龄分级 + $inner: + - 全年龄 + - R18 + - R18G + ai: + $description: 是否允许搜索AI作品 + $inner: + - 不允许AI作品 + - 允许AI作品 + - bypassMethod: + $description: 突破 Pixiv 站点图片防外部引用检测的方式。[参考](https://booru.koishi.chat/zh-CN/plugins/pixiv.html#bypass-pixiv-detection) + $inner: + - 使用现有反代服务 + - 使用插件本地反代 + - 下载到 assets 缓存 + proxy: + $description: Pixiv 反代服务。 + $inner: + - i.pixiv.re + - i.pixiv.cat + - i.pixiv.nl + - $description: 自定义 + endpoint: 反代服务的地址。 + route: 反代服务的路径(需在 server 插件配置中填写 `selfUrl`)。 + aesKey: AES 加密密钥 diff --git a/packages/safebooru/src/index.ts b/packages/safebooru/src/index.ts index dd6de2a10..8dc026189 100644 --- a/packages/safebooru/src/index.ts +++ b/packages/safebooru/src/index.ts @@ -60,8 +60,10 @@ namespace SafebooruImageSource { export const Config: Schema = Schema.intersect([ ImageSource.createSchema({ label: 'safebooru' }), Schema.object({ - endpoint: Schema.string().description('Safebooru 的 URL。').default('https://safebooru.org/index.php'), - }).description('搜索设置'), + endpoint: Schema.string().default('https://safebooru.org/index.php'), + }).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/safebooru/src/locales/zh-CN.schema.yml b/packages/safebooru/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..633adee95 --- /dev/null +++ b/packages/safebooru/src/locales/zh-CN.schema.yml @@ -0,0 +1,2 @@ +$description: 搜索设置 +endpoint: Safebooru 的 URL。 diff --git a/packages/sankaku/src/index.ts b/packages/sankaku/src/index.ts index ee555b572..fce40ac71 100644 --- a/packages/sankaku/src/index.ts +++ b/packages/sankaku/src/index.ts @@ -96,19 +96,19 @@ namespace SankakuComplexImageSource { Schema.object({ keyPairs: Schema.array( Schema.object({ - login: Schema.string().required().description('SankakuComplex 用户名'), - password: Schema.string().required().role('secret').description('SankakuComplex 密码'), - tokenType: Schema.string().hidden().default('Bearer').description('SankakuComplex 访问令牌类型'), - accessToken: Schema.string().hidden().description('SankakuComplex 访问令牌'), + login: Schema.string().required(), + password: Schema.string().required().role('secret'), + tokenType: Schema.string().hidden().default('Bearer'), + accessToken: Schema.string().hidden(), }), - ) - .default([]) - .description('SankakuComplex 的登录凭证'), - userAgent: Schema.string().description('设置请求的 User Agent。').default( + ).default([]), + userAgent: Schema.string().default( // eslint-disable-next-line max-len 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36', ), - }).description('搜索设置'), + }).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/sankaku/src/locales/zh-CN.schema.yml b/packages/sankaku/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..3add10876 --- /dev/null +++ b/packages/sankaku/src/locales/zh-CN.schema.yml @@ -0,0 +1,9 @@ +$description: 搜索设置 +keyPairs: + $description: SankakuComplex 的登录凭证 + $inner: + login: SankakuComplex 用户名 + password: SankakuComplex 密码 + tokenType: SankakuComplex 访问令牌类型 + accessToken: SankakuComplex 访问令牌 +userAgent: 设置请求的 User Agent。 diff --git a/packages/yande/src/index.ts b/packages/yande/src/index.ts index dedac8869..067644d3d 100644 --- a/packages/yande/src/index.ts +++ b/packages/yande/src/index.ts @@ -79,16 +79,16 @@ namespace YandeImageSource { export const Config: Schema = Schema.intersect([ ImageSource.createSchema({ label: 'yande' }), Schema.object({ - endpoint: Schema.string().description('Yande.re 的 URL。').default('https://yande.re'), + endpoint: Schema.string().default('https://yande.re'), keyPairs: Schema.array( Schema.object({ - login: Schema.string().required().description('Yande.re 的用户名。'), - password: Schema.string().required().role('secret').description('Yande.re 的密码。'), + login: Schema.string().required(), + password: Schema.string().required().role('secret'), }), - ) - .default([]) - .description('Yande.re 的登录凭据。'), - }).description('搜索设置'), + ).default([]), + }).i18n({ + 'zh-CN': require('./locales/zh-CN.schema'), + }), ]) } diff --git a/packages/yande/src/locales/zh-CN.schema.yml b/packages/yande/src/locales/zh-CN.schema.yml new file mode 100644 index 000000000..0dd96499e --- /dev/null +++ b/packages/yande/src/locales/zh-CN.schema.yml @@ -0,0 +1,7 @@ +$description: 搜索设置 +endpoint: Yande.re 的 URL。 +keyPairs: + $description: Yande.re 的登录凭据。 + $inner: + login: Yande.re 的用户名。 + password: Yande.re 的密码。