我想在国际化我的GWT应用程序。阅读文档后,我看不出使用常量而不是消息的原因。消息似乎在各方面都更加强大。
有没有理由使用常数?他们是否比消息有更好的表现或任何其他优势?
答案 0 :(得分:7)
消息只是关于字符串,而常量可以包含数字,布尔值,字符串数组等。
答案 1 :(得分:0)
不一定是不使用消息的理由,但有一点值得注意。使用Messages接口时,需要转义包含单引号(')的.properties文件中定义的字符串。使用Constants接口时,这不是必需的。例如,如果您有以下界面:
MyMessages.java
public interface MyMessages extends Messages {
@DefaultMessage("Please")
String please();
}
MyMessages_fr.properties
# this will throw a java.text.ParseException: Unterminated single quote
please = S'il vous plaît
# this will be parsed correctly and will display with only 1 single quote
please = S''il vous plaît