OGeek|极客世界-中国程序员成长平台

标题: iphone - ICU 在 iOS 上的 MessageFormat [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 03:57
标题: iphone - ICU 在 iOS 上的 MessageFormat

据我了解,iOS 在后台使用 ICU。我想为涉及数字和复数的字符串访问 ICU 的 MessageFormat 的功能,例如,

There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}.

iOS 是否公开此功能?如果是这样,我该如何使用它?我想我可能会写

[NSString stringWithFormat: "There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}.", n];

[NSString stringWithFormat: "There {0,plural, =0{are no files}=1{is one file}other{are %ld files}}.", n];

但这些格式(分别为 ICU4J 和 ICU)不起作用。



Best Answer-推荐答案


iOS 和 OS X 一样,确实包含 /usr/lib/libicucore.dylib。但是,它在任一操作系统上都不是受支持的公共(public) API。见 this old message了解如何在 OS X 上使用它,以及潜在的问题是什么。

在 iOS 上,我猜还有一个问题是 Apple 可能会拒绝您的应用程序使用不受支持的 API。

关于iphone - ICU 在 iOS 上的 MessageFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10367735/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4