Skip to content

beowulf13th/yaml-resource-bundle

Repository files navigation

Yaml Resource Bundle

Can be use with Spring Framework

Instructions

  • 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

Features

bundle.getString("top.sub.check");
// returns string value
bundle.getObject("top.sub-another.may-be-array");
// returns list of objects
bundle.getObject("top.sub-another.may-be-array.size");
// returns size of list
bundle.getObject("top.sub-another.may-be-array[0].text");
// returns field value of array object
bundle.getObject("top.sub-another.list-of-value[0]");
// returns array value by index

Releases

No releases published

Packages

No packages published

Languages