gpt4 book ai didi

icu - 如何在 ICU 中表达列表

转载 作者:行者123 更新时间:2023-12-05 07:55:44 26 4
gpt4 key购买 nike

我正在尝试学习 ICU 语法并希望能够表达在 ICU message format 中列出.

例如,给定数据:

items:
- cool
- handy
- neat

我希望能够生成如下消息:

StackOverflow is cool, handy, and neat.

StackOverflow is cool and handy and nice.

即。我希望能够定义如何构建列表。

在 ICU 消息语法中这完全可能吗?

最佳答案

据我所知,ICU 消息语法不支持列表。

一个潜在的解决方法是检查您的平台是否支持他们的列表本地化实现(例如 Android)或将“列表逻辑”包装到 ICU Select 类型的消息中。

ICU 选择消息示例:

{
type,
select,
comma {StackOverflow is cool, handy, and neat.}
and {StackOverflow is cool and handy and nice.}
other {StackOverflow is: cool, handy, and nice.}
}

请注意,ICU 消息可能很笨拙且难以维护。
一些免费的在线 ICU 编辑器可以帮助您轻松检查和验证它​​们(例如 DevPal ICU message editor )。

关于icu - 如何在 ICU 中表达列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29365472/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com