如何检索所有Spring Boot I18N消息

时间:2017-09-11 21:32:53

标签: spring spring-boot internationalization

我需要检索文件messages_en.propertiesmessages_es.properties等中的所有邮件,具体取决于当前的区域设置,但到目前为止,我找不到获取超过值的方法属性。

我需要的只是返回与当前语言环境相对应的所有翻译,以便我可以在前端处理Angularjs的国际化。

提前致谢,

1 个答案:

答案 0 :(得分:-1)

您可以使用plain old Java to load all entries of a properties file

Properties properties = new Properties();
InputStream in = getClass().getResourceAsStream("messages_en.properties");
properties.load(in);
in.close();
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
   System.out.println(entry.getKey() + " -> " + entry.getValue());
}