![](/img/trans.png)
[英]How Do I Use/Import my Java Locale class and Resource Bundle properties to be used in my HTML files (not JSP)?
[英]How to use resource bundle files in Java code?
我已經在JSTL <fmt>
標簽庫可以使用的資源包文件中獲得了本地化消息。 現在,我也想從Java代碼中使用這些消息。 如何做呢?
我需要的是類似key的getMessage()
和帶有參數的key的getParameterizedMessage()
。
更新以下似乎有效:
ResourceBundle messages = ResourceBundle.getBundle("messages");
String str = messages.getString("PF1");
System.out.println(str);
Object[] messageArguments = {
"test"
};
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(messages.getString("IT4"));
String output = formatter.format(messageArguments);
System.out.println(output);
將您的消息加載到java.util.Properties
並具有一個幫助程序類,如果提供了鍵,它將返回“屬性”中的值。
如果您正在尋找I18支持,則可以在此處找到入門基礎
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.