[英]Is it possible to accept a string array as argument in corba idl file
[英]ResourceBundle/Propertie file to accept array of String in argument {0}
有没有一种方法可以将String数组传递给资源束,以对给定键本地化未知数量的参数?
我有:
my.message=List of retired products: {0}
getValue(bundle, "my.message", list.toArray());
这样,结果消息中仅显示数组中的第一项。
不, MessageFormat
API中没有内置的功能。 您需要自己使用值构建一个字符串。 例如:
StringBuilder products = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
products.append(list.get(i));
if (i + 2 < list.size()) products.append(", ");
else if (i + 2 == list.size()) products.append(" and "); // Localize this?
}
getValue(bundle, "my.message", products);
我认为您将需要一个for
循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.