简体   繁体   English

如何检索所有Spring Boot I18N消息

[英]How to retrieve all Spring Boot I18N Messages

I need to retrieve all the messages I have in the file messages_en.properties , messages_es.properties , etc. depending of the current locale, but so far I can not find a way to get more than the value of a property. 我需要根据当前的语言环境来检索文件messages_en.propertiesmessages_es.properties等中所有的消息,但是到目前为止,我找不到除属性值之外的方法。

What I need is nothing more than to return all the translations corresponding to the current locale, so that I can handle the internationalization with Angularjs in the front end. 我所需要的只是返回与当前语言环境相对应的所有翻译,以便我可以在前端使用Angularjs处理国际化。

Thanks in advance, 提前致谢,

You can use plain old Java to load all entries of a properties file : 您可以使用普通的旧Java来加载属性文件的所有条目

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());
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM