diff --git a/README.md b/README.md index f071212..5377d01 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,59 @@ +> [!IMPORTANT] +> Work in progress. + # Base package to provide a custom MessageSource for Spring and Spring Boot [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=alaugks_spring-messagesource-base&metric=alert_status&token=3d2b79af1f0f0ab6089e565495b4db6f621e9a13)](https://sonarcloud.io/summary/overall?id=alaugks_spring-messagesource-base) + +## Dependency + +```xml + + + io.github.alaugks + spring-messagesource-base + 0.0.3-SNAPSHOT + + +``` + +## Configuration +```java +import io.github.alaugks.spring.messagesource.base.catalog.Catalog; +import io.github.alaugks.spring.messagesource.base.catalog.CatalogHandler; +import io.github.alaugks.spring.messagesource.base.records.Translation; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MessageConfig { + + @Bean + public MessageSource messageSource() { + + List translations = new ArrayList<>(); + translations.add(new Translation(Locale.forLanguageTag("en"), "hello_world", "Hello World")); + translations.add(new Translation(Locale.forLanguageTag("de"), "hello_world", "Hallo Welt")); + + return new BaseTranslationMessageSource( + CatalogHandler + .builder() + .addHandler( + new Catalog( + translations, + Locale.forLanguageTag("en") + ) + ) + .build() + ); + } +} +``` + +## Translation Sources + +* [XLIFF 2.0.0-SNAPSHOT](https://github.com/alaugks/spring-messagesource-xliff/tree/snapshot/2.0.0) diff --git a/pom.xml b/pom.xml index 8268f0f..368469d 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ spring-messagesource-base - 0.0.2-SNAPSHOT + 0.0.3-SNAPSHOT jar ${project.groupId}:${project.artifactId}