Skip to content

Commit

Permalink
chore: setup i18n for mysql, mongo, sqlite, hmr plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed May 18, 2023
1 parent 9784b9c commit e75a620
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 16 deletions.
2 changes: 2 additions & 0 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
commit_message: '[skip ci]'
pull_request_title: 'i18n: update translations'
pull_request_labels:
- i18n
files:
- source: /**/src/locales/zh-CN.yml
translation: /%original_path%/%locale%.yml
skip_untranslated_strings: true
14 changes: 8 additions & 6 deletions plugins/database/mongo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { defineDriver, Schema } from 'koishi'
import { MongoDriver } from '@minatojs/driver-mongo'

export default defineDriver(MongoDriver, Schema.object({
protocol: Schema.string().description('要使用的协议名。').default('mongodb'),
host: Schema.string().description('要连接到的主机名。').default('localhost'),
port: Schema.natural().max(65535).description('要连接到的端口号。'),
username: Schema.string().description('要使用的用户名。'),
password: Schema.string().description('要使用的密码。').role('secret'),
database: Schema.string().description('要访问的数据库名。').default('koishi'),
protocol: Schema.string().default('mongodb'),
host: Schema.string().default('localhost'),
port: Schema.natural().max(65535),
username: Schema.string(),
password: Schema.string().role('secret'),
database: Schema.string().default('koishi'),
}).i18n({
'zh-CN': require('./locales/zh-CN'),
}))
6 changes: 6 additions & 0 deletions plugins/database/mongo/src/locales/zh-CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
protocol: 要使用的协议名。
host: 要连接到的主机名。
port: 要连接到的端口号。
username: 要使用的用户名。
password: 要使用的密码。
database: 要访问的数据库名。
12 changes: 7 additions & 5 deletions plugins/database/mysql/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { defineDriver, Schema } from 'koishi'
import { MySQLDriver } from '@minatojs/driver-mysql'

export default defineDriver(MySQLDriver, Schema.object({
host: Schema.string().description('要连接到的主机名。').default('localhost'),
port: Schema.natural().max(65535).description('要连接到的端口号。').default(3306),
user: Schema.string().description('要使用的用户名。').default('root'),
password: Schema.string().description('要使用的密码。').role('secret'),
database: Schema.string().description('要访问的数据库名。').default('koishi'),
host: Schema.string().default('localhost'),
port: Schema.natural().max(65535).default(3306),
user: Schema.string().default('root'),
password: Schema.string().role('secret'),
database: Schema.string().default('koishi'),
}).i18n({
'zh-CN': require('./locales/zh-CN'),
}))
5 changes: 5 additions & 0 deletions plugins/database/mysql/src/locales/zh-CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
host: 要连接到的主机名。
port: 要连接到的端口号。
user: 要使用的用户名。
password: 要使用的密码。
database: 要访问的数据库名。
4 changes: 3 additions & 1 deletion plugins/database/sqlite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { SQLiteDriver } from '@minatojs/driver-sqlite'
import path from 'path'

export default defineDriver(SQLiteDriver, Schema.object({
path: Schema.string().description('数据库路径').default('.koishi.db'),
path: Schema.string().default('.koishi.db'),
}).i18n({
'zh-CN': require('./locales/zh-CN'),
}), (ctx, config) => {
if (config.path !== ':memory:') {
config.path = path.resolve(ctx.baseDir, config.path)
Expand Down
1 change: 1 addition & 0 deletions plugins/database/sqlite/src/locales/zh-CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
path: 数据库路径。
10 changes: 6 additions & 4 deletions plugins/hmr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,20 +319,22 @@ namespace Watcher {
}

export const Config: Schema<Config> = Schema.object({
base: Schema.string().description('用户显示路径的根目录,默认为当前工作路径。'),
base: Schema.string(),
root: Schema.union([
Schema.array(String).role('table'),
Schema.transform(String, (value) => [value]),
]).default(['.']).description('要监听的文件或目录列表,相对于 `base` 路径。'),
]).default(['.']),
ignored: Schema.union([
Schema.array(String).role('table'),
Schema.transform(String, (value) => [value]),
]).default([
'**/node_modules/**',
'**/.git/**',
'**/logs/**',
]).description('要忽略的文件或目录。支持 [Glob Patterns](https://github.com/micromatch/micromatch) 语法。'),
debounce: Schema.natural().role('ms').default(100).description('延迟触发更新的等待时间。'),
]),
debounce: Schema.natural().role('ms').default(100),
}).i18n({
'zh-CN': require('./locales/zh-CN'),
})
}

Expand Down
4 changes: 4 additions & 0 deletions plugins/hmr/src/locales/zh-CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
base: 用户显示路径的根目录,默认为当前工作路径。
root: 要监听的文件或目录列表,相对于 `base` 路径。
ignored: 要忽略的文件或目录。支持 [Glob Patterns](https://github.com/micromatch/micromatch) 语法。
debounce: 延迟触发更新的等待时间。

0 comments on commit e75a620

Please sign in to comment.