# 我认为 MessageFormat 在复数形式多于或少于英语的语言中存在问题

**URL:** https://meta.discourse.org/t/there-is-a-problem-with-messageformat-and-languages-with-a-country-code-like-pl-pl-and-zh-cn/394016
**Category:** Bug
**Tags:** translation
**Created:** [2026年一月21日 19:56 UTC](https://meta.discourse.org/t/there-is-a-problem-with-messageformat-and-languages-with-a-country-code-like-pl-pl-and-zh-cn/394016 "2026-01-21T19:56:12Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2026年一月21日 19:56 UTC](https://meta.discourse.org/t/there-is-a-problem-with-messageformat-and-languages-with-a-country-code-like-pl-pl-and-zh-cn/394016/1 "2026-01-21T19:56:12Z")

</div>

继续讨论自 [Message Format support for localization](https://meta.discourse.org/t/message-format-support-for-localization/7035)：

> [@Discourse](#):
>
> **重要提示：** 如果您的语言使用的复数形式多于“one”和“other”两种，则需要修改翻译中的复数形式。您可以通过在 `{ FOO, plural, ... }` 块中添加或删除形式来使其适用于您的语言。

我在用不同语言测试我的文本与 MessageFormat 时遇到了问题，因为它在波兰语中不起作用。

但在查看现有文本后，我认为问题不在我这边，而是某些地方没有按预期工作。

我查看的示例在邀请模态框中：`js.user.invited.invite.link_validity_MF`

## 英文中一切正常：

> <https://github.com/discourse/discourse/blob/50799f3557a6db6c816913315604ee5922cab7a0/config/locales/client.en.yml#L2272-L2279>

 ![image](https://global.discourse-cdn.com/meta/original/4X/6/0/0/60086081b78cee67cbafeb00d184e4daa0f0b2ec.png)

## 德语中也有效：

> <https://github.com/discourse/discourse/blob/50799f3557a6db6c816913315604ee5922cab7a0/config/locales/client.de.yml#L2116-L2124>

 ![image](https://global.discourse-cdn.com/meta/original/4X/e/a/1/ea1601ad99342190dd126f8fca476732c1fa37cb.png)

## 但在波兰语中无效：

> <https://github.com/discourse/discourse/blob/50799f3557a6db6c816913315604ee5922cab7a0/config/locales/client.pl_PL.yml#L2343-L2354>

 ![image](https://global.discourse-cdn.com/meta/original/4X/e/4/b/e4bced96c1abadc8305a56a8ccc232ef29b92e72.png)

## 在中文中也无效：

> <https://github.com/discourse/discourse/blob/50799f3557a6db6c816913315604ee5922cab7a0/config/locales/client.zh_CN.yml#L2027-L2032>

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/c/3/5c3248cb721acc6ff99bd6eb8585a670b0bd864f.png)

根据文档主题，我期望所有这些翻译都能工作，而不仅仅是德语翻译。因此，我怀疑在影响具有不同复数数量的语言的地方存在错误。

---

<div class="post-metadata">

### Author: ![small-lovely-cat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/small-lovely-cat/32/553546_2.png) [@small-lovely-cat](https://meta.discourse.org/u/small-lovely-cat)
#### Post date: [2026年一月22日 09:51 UTC](https://meta.discourse.org/t/there-is-a-problem-with-messageformat-and-languages-with-a-country-code-like-pl-pl-and-zh-cn/394016/2 "2026-01-22T09:51:18Z")

</div>

是的，同样的问题，使用的是 zh-CN。

所有以 MF 结尾的语言字符串都已损坏，并以 en-US 格式显示。

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2026年一月22日 10:06 UTC](https://meta.discourse.org/t/there-is-a-problem-with-messageformat-and-languages-with-a-country-code-like-pl-pl-and-zh-cn/394016/3 "2026-01-22T10:06:08Z")

</div>

感谢您的报告！您认为这可能是由最近的更改引起的吗？还是它一直都是这样？🤔

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2026年一月22日 10:27 UTC](https://meta.discourse.org/t/there-is-a-problem-with-messageformat-and-languages-with-a-country-code-like-pl-pl-and-zh-cn/394016/4 "2026-01-22T10:27:32Z")

</div>

我不知道。德语运行正常，所以我通常看不到有什么东西坏了。我昨天第一次使用 messageFormat 并选择波兰语进行测试时才注意到。如果消息不够多，“倒回聊天”部分会被隐藏，所以为了测试“其他”部分以外的内容，我想要一种具有多种复数形式的语言。

我刚刚尝试了一个基于稳定分支的开发安装，它在那里似乎可以工作：

 ![Screenshot_20260122_112645_Firefox](https://global.discourse-cdn.com/meta/original/4X/5/6/c/56c6d940d55c66c32c43ae8107db3f34eae68c10.jpeg)  
 ![Screenshot_20260122_112613_Firefox](https://global.discourse-cdn.com/meta/original/4X/3/4/3/34321476c51c654d570b985e4487ce2491daaad8.jpeg)

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2026年一月22日 10:47 UTC](https://meta.discourse.org/t/there-is-a-problem-with-messageformat-and-languages-with-a-country-code-like-pl-pl-and-zh-cn/394016/5 "2026-01-22T10:47:53Z")

</div>

我认为这可以解决问题：

> <https://github.com/discourse/discourse/pull/37268>
>
> Messageformat takes locale names in a slightly different format to the rest of o…ur translation system
> 
> Followup to d7de0f67350a53e7ed250f0015a88415e4c043ec

润色：

 ![SCR-20260122-jwwl](https://global.discourse-cdn.com/meta/original/4X/c/8/3/c836bf1b53b12a0eabdeb5c49b9f5794027e45de.png)

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2026年一月22日 10:55 UTC](https://meta.discourse.org/t/there-is-a-problem-with-messageformat-and-languages-with-a-country-code-like-pl-pl-and-zh-cn/394016/7 "2026-01-22T10:55:57Z")

</div>

所以，我在测试时选择了带有国家代码的波兰语，这真是太倒霉了，如果我选择了乌克兰语，一切都会顺利进行 😢 那样会为我节省很多时间。

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2026年一月24日 08:00 UTC](https://meta.discourse.org/t/there-is-a-problem-with-messageformat-and-languages-with-a-country-code-like-pl-pl-and-zh-cn/394016/8 "2026-01-24T08:00:07Z")

</div>

此主题在 42 小时后自动关闭。不再允许回复。
