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: I18n 语言列表回退顺序没有遵循期望 #1464

Open
dingyi222666 opened this issue Oct 5, 2024 · 1 comment
Open

Bug: I18n 语言列表回退顺序没有遵循期望 #1464

dingyi222666 opened this issue Oct 5, 2024 · 1 comment
Labels

Comments

@dingyi222666
Copy link

Describe the bug

我安装了杂鱼语言包,并且设置回退顺序为
image

然后测试了命令,结果是没有成功把内容本地化。

image

Steps to reproduce

如需在 Koishi 实例上重现,只需安装并启用 locale-zh-cn-zako ,设置下图的回退顺序:

image

运行 help help 即可看到没有成功本地化的命令输出:

image


代码复现:

import { fallback, LocaleTree } from '@koishijs/i18n-utils'

const locales = ['zh-CN-ZAKO', 'en-US', 'zh-CN']
const tree = LocaleTree.from(locales)

console.log(fallback(tree, []))

运行上面的代码,输出:

[ '', 'zh', 'zh-CN', 'zh-CN-ZAKO', 'en', 'en-US' ]

Expected behavior

手动设置用户语言为相应语言,则可成功本地化:

image


上面的代码应该输出:

[ '','zh-CN-ZAKO','zh-CN','zh', 'en-US','en']

理论应是细分类优先,并且按照传入 fallbacklocalesLocaleTree.from 的传入顺序排序

Screenshots

No response

Versions

  • OS: Windows 11
  • Platform: Sandbox
  • Node version: v20.15.0
  • Koishi version: 4.18.0

Additional context

No response

@dingyi222666 dingyi222666 added the bug BUG label Oct 5, 2024
@shigma
Copy link
Member

shigma commented Oct 7, 2024

好像是有一点点设计上的缺陷,我看看如何调整一下这里的语义。

@shigma shigma added the i18n label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants