MessageFormat.format(arg0, arg1)的用途--多语处理
MessageFormat.format(arg0, arg1)在做多语言处理时很有用处。
他支持指定参数插入位置,便于多语支持人员在翻译后正确的调整字符串参数出现的位置。特别是在某些中文描述,在翻译为其他语种时可能采用倒序方式,那么参数就应该调整出现的位置。
例如:
MessageFormat用来格式化一个消息,通常是一个字符串,比如:
String str = "I'm {0}, age is {1,number,short}", height is {2,number,#.#};
MessageFormat.format(str,”Tommy”,10,175)