https://github.com/xdean/nest-message-spring-boot
Spring Nest Message Support
https://github.com/xdean/nest-message-spring-boot
i18n messagesource spring spring-boot
Last synced: 2 months ago
JSON representation
Spring Nest Message Support
- Host: GitHub
- URL: https://github.com/xdean/nest-message-spring-boot
- Owner: XDean
- License: apache-2.0
- Created: 2018-04-22T11:30:32.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-25T10:07:59.000Z (about 8 years ago)
- Last Synced: 2025-12-31T08:33:50.625Z (6 months ago)
- Topics: i18n, messagesource, spring, spring-boot
- Language: Java
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nest Message Spring Boot
[](https://travis-ci.org/XDean/nest-message-spring-boot)
[](https://codecov.io/gh/XDean/nest-message-spring-boot/branch/master)
[](https://maven-badges.herokuapp.com/maven-central/com.github.XDean/nest-message-spring-boot)
Nest Message Spring Boot
# Motivation
Reduce duplicate string in message source.
# Get Start
1. If you are using `@EnableAutoConfiguration`, just add the dependency:
```xml
com.github.XDean
nest-message-spring-boot-starter
x.x
```
2. If you are not using `@EnableAutoConfiguration`, add the dependency:
```xml
com.github.XDean
nest-message-spring-boot
x.x
```
and add `@EnableNestMessageSource` on your configuration class:
```java
@Configuration
@EnableNestMessageSource
public class MyApplication{
...
}
```
# Usage
### Use nest message expression
```csv
hello.guy=Hello {0}!
hello.world=$(hello.guy,world)
```
`hello.world` will be `Hello World!`
### Use argument placeholder
```csv
hello.two=Hello {0} and {1}!
hello.owt=$(hello.two,$1,$0)
```
`hello.world` with `{a, b}` will be `Hello b and a!`
### Complex expression with escaper and quoter
```csv
book.name=<{0}>
book.price=\${0,number,#.#}
book.promote=Come to buy {0} with $(book.price,$1)
java.promote=Hello guys! $(book.promote,$(book.name,java)"(2nd edition)",{0})
```
`java.promote` with `{123}` will be
`Hello guys! Come to buy (2nd edition) with $123`
# Configuration
Properties prefix is `xdean.message.nest`
Property | Description | Effect out of expression | Default Value
--- | --- | --- | ---
`prefix` | start a nest message expression | true | `$(`
`suffix` | end a nest message expression | false | `)`
`splitor` | splitor in nest message expression | false | `,`
`escaper` | escaper in nest message expression | true | `\`
`quoter` | quoter in nest message expression | false | `"`
`argPrefix` | argument placeholder prefix in nest message expression | false | `$`