Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: 指令参数无效的提示未正确翻译 #1472

Open
DGCK81LNN opened this issue Oct 26, 2024 · 1 comment
Open

Bug: 指令参数无效的提示未正确翻译 #1472

DGCK81LNN opened this issue Oct 26, 2024 · 1 comment
Labels
bug BUG

Comments

@DGCK81LNN
Copy link
Contributor

DGCK81LNN commented Oct 26, 2024

Describe the bug

执行指令参数指定有误时返回的错误提示总是使用缺省语言。

Steps to reproduce

  1. 确保全局设置 i18n.locales 的首项为 zh 或以 zh- 开头
  2. channel.locale en-US, user.locale en-US
  3. authorize -u @Alice foobar 返回:参数 value 输入无效,应为自然数。
  4. 修改全局设置 i18n.locales 的首项为 en 或以 en- 开头
  5. authorize -u @Alice foobar 返回:Invalid argument value, Expect a non-negative integer.
  6. channel.locale zh-CN, user.locale zh-CN
  7. authorize -u @Alice foobar 仍然返回:Invalid argument value, Expect a non-negative integer.

Expected behavior

以当前会话的首选语言显示该提示。

Screenshots

No response

Versions

  • OS: Windows 10
  • Platform: onebot
  • Node version: 22.9.0
  • Koishi version: 4.18.0

Additional context

session.text() 被调用时,似乎还在进行 attach-user 的过程中,argv.session.userargv.session.channel 均为 undefined;大致调用栈:

const message = argv.session.text(err['message'] || 'internal.check-syntax')
argv.error = argv.session.text(`internal.invalid-${kind}`, [name, message])

args.push(this.ctx.$commander.parseValue(content, 'argument', argv, argDecl))

const { options, args, error } = argv.command.parse(argv)

if (!this.app.$commander.resolveCommand(argv)) return

if (argv) collect(argv)

session.collect('user', session.argv, fields)

this.ctx.emit('before-attach-user', session, userFields)

@DGCK81LNN DGCK81LNN added the bug BUG label Oct 26, 2024
@DGCK81LNN DGCK81LNN changed the title Bug: internal.invalid-argument 未正确选择本地化语言 Bug: 指令参数无效的提示未正确本地化 Oct 26, 2024
@DGCK81LNN DGCK81LNN changed the title Bug: 指令参数无效的提示未正确本地化 Bug: 指令参数无效的提示未正确翻译 Oct 26, 2024
@DGCK81LNN
Copy link
Contributor Author

或许 related to #1414

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug BUG
Projects
None yet
Development

No branches or pull requests

1 participant