Commit a21d8fc1 authored by nanahira's avatar nanahira

add DefineLocale

parent 71c64a9e
...@@ -3,7 +3,6 @@ import { ...@@ -3,7 +3,6 @@ import {
CommandConfigExtended, CommandConfigExtended,
CommandDefinitionFun, CommandDefinitionFun,
CommandOptionConfigWithDescription, CommandOptionConfigWithDescription,
ContextFunction,
EventName, EventName,
KoishiCommandDefinition, KoishiCommandDefinition,
KoishiCommandPutDef, KoishiCommandPutDef,
...@@ -14,12 +13,12 @@ import { ...@@ -14,12 +13,12 @@ import {
import 'reflect-metadata'; import 'reflect-metadata';
import { import {
Argv, Argv,
Awaitable,
Command, Command,
Dict, Dict,
FieldCollector, FieldCollector,
Selection, Selection,
Session, Session,
Store,
} from 'koishi'; } from 'koishi';
import { Metadata } from '../meta/metadata.decorators'; import { Metadata } from '../meta/metadata.decorators';
import { CommandPut, DoRegister } from '../registry'; import { CommandPut, DoRegister } from '../registry';
...@@ -221,3 +220,9 @@ export const DefineTemplate = (name: string, text: string | Dict<string>) => ...@@ -221,3 +220,9 @@ export const DefineTemplate = (name: string, text: string | Dict<string>) =>
TopLevelAction((ctx) => TopLevelAction((ctx) =>
registerTemplate({ name, text: adaptLocaleDict(text) }, ctx), registerTemplate({ name, text: adaptLocaleDict(text) }, ctx),
); );
export const DefineLocale = (
locale: string,
key: string,
text: string | Store,
) => TopLevelAction((ctx) => ctx.i18n.define(locale, key, text));
// metadatas // metadatas
import { import {
CommandDefinitionFun, CommandDefinitionFun,
ContextFunction,
OnContextFunction, OnContextFunction,
TopLevelActionDef, TopLevelActionDef,
} from './interfaces'; } from './interfaces';
import { DoRegister } from '../registry'; import { DoRegister } from '../registry';
import { Awaitable } from 'koishi';
export const KoishiOnContextScope = 'KoishiOnContextScope'; export const KoishiOnContextScope = 'KoishiOnContextScope';
export const KoishiDoRegister = 'KoishiDoRegister'; export const KoishiDoRegister = 'KoishiDoRegister';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment