Can be use with Spring Framework
- Add dependency to Maven / Gradle project:
implementation 'ru.maksimvoloshin.utility:yaml-resource-bundle:0.1'<dependency>
<groupId>ru.maksimvoloshin.utility</groupId>
<artifactId>yaml-resource-bundle</artifactId>
<version>0.1</version>
</dependency>- Create a little configuration:
@Bean
ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource messageSource = new YamlResourceBundleMessageSource();
messageSource.setBasename("messages");
messageSource.setDefaultEncoding("utf-8");
return messageSource;
}- Just inject bean in a project and use as usually
bundle.getString("top.sub.check");
// returns string valuebundle.getObject("top.sub-another.may-be-array");
// returns list of objectsbundle.getObject("top.sub-another.may-be-array.size");
// returns size of listbundle.getObject("top.sub-another.may-be-array[0].text");
// returns field value of array objectbundle.getObject("top.sub-another.list-of-value[0]");
// returns array value by index