We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0cb2a82 commit eb3b5f9Copy full SHA for eb3b5f9
server/packages/sdk/src/services/base.ts
@@ -232,10 +232,19 @@ export abstract class TcService extends Service {
232
ctx: Context<unknown, { language: string; t: TFunction }>
233
) {
234
// 调用时生成t函数
235
- ctx.meta.t = (key: string, defaultValue?: string) =>
236
- t(key, defaultValue, {
+ ctx.meta.t = (key: string, defaultValue?: string | object) => {
+ if (typeof defaultValue === 'object') {
237
+ // 如果是参数对象的话
238
+ return t(key, {
239
+ ...defaultValue,
240
+ lng: ctx.meta.language,
241
+ });
242
+ }
243
+
244
+ return t(key, defaultValue, {
245
lng: ctx.meta.language,
246
});
247
+ };
248
return handler.call(this, ctx);
249
},
250
};
0 commit comments