File tree Expand file tree Collapse file tree 5 files changed +13
-82
lines changed
main/java/dev/alaugks/spring/messagesource/json
test/java/dev/alaugks/spring/messagesource/json Expand file tree Collapse file tree 5 files changed +13
-82
lines changed Original file line number Diff line number Diff line change 1
1
# Example: Custom JSON Spring MessageSource
2
2
3
3
4
- This example shows how to use the [ spring-messagesource-catalogue] ( https://github.com/alaugks/spring-messagesource-catalog ) to implement a MessageSource from translations in JSON files.
5
-
4
+ This example shows how to use [ spring-messagesource-json] ( https://github.com/alaugks/spring-messagesource-json ) .
6
5
7
6
## Build and Run Docker Image
8
7
Original file line number Diff line number Diff line change 7
7
<parent >
8
8
<groupId >org.springframework.boot</groupId >
9
9
<artifactId >spring-boot-starter-parent</artifactId >
10
- <version >3.3.4 </version >
10
+ <version >3.4.2 </version >
11
11
<relativePath />
12
12
</parent >
13
13
45
45
46
46
<dependency >
47
47
<groupId >io.github.alaugks</groupId >
48
- <artifactId >spring-messagesource-catalog </artifactId >
49
- <version >0.4 .0</version >
48
+ <artifactId >spring-messagesource-json </artifactId >
49
+ <version >0.1 .0</version >
50
50
</dependency >
51
51
52
52
<dependency >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
package dev .alaugks .spring .messagesource .json .config ;
2
2
3
+ import io .github .alaugks .spring .messagesource .catalog .resources .LocationPattern ;
4
+ import io .github .alaugks .spring .messagesource .json .JsonResourceMessageSource ;
3
5
import java .util .Locale ;
4
-
5
- import dev .alaugks .spring .messagesource .json .catalog .JsonCatalog ;
6
- import io .github .alaugks .spring .messagesource .catalog .CatalogMessageSourceBuilder ;
7
-
8
6
import org .springframework .context .MessageSource ;
9
7
import org .springframework .context .annotation .Bean ;
10
8
import org .springframework .context .annotation .Configuration ;
@@ -14,9 +12,10 @@ public class MessageSourceConfig {
14
12
15
13
@ Bean
16
14
public MessageSource messageSource () {
17
- return CatalogMessageSourceBuilder
18
- .builder (new JsonCatalog (), Locale .forLanguageTag ("en" ))
19
- .build ();
15
+ return JsonResourceMessageSource .builder (
16
+ Locale .forLanguageTag ("en" ),
17
+ new LocationPattern ("messages/*" )
18
+ ).build ();
20
19
}
21
20
22
21
}
Original file line number Diff line number Diff line change 1
1
package dev .alaugks .spring .messagesource .json ;
2
2
3
- import dev .alaugks .spring .messagesource .json .catalog .JsonCatalog ;
3
+ import static org .assertj .core .api .Assertions .assertThat ;
4
+
4
5
import dev .alaugks .spring .messagesource .json .config .MessageSourceConfig ;
5
6
import dev .alaugks .spring .messagesource .json .config .WebMvcConfigurerConfig ;
6
7
import dev .alaugks .spring .messagesource .json .controller .IndexController ;
7
8
import org .junit .jupiter .api .Test ;
8
-
9
9
import org .springframework .beans .factory .annotation .Autowired ;
10
10
import org .springframework .boot .test .autoconfigure .web .servlet .WebMvcTest ;
11
11
import org .springframework .context .annotation .Import ;
15
15
import org .springframework .test .web .servlet .request .MockMvcRequestBuilders ;
16
16
import org .springframework .test .web .servlet .result .MockMvcResultMatchers ;
17
17
18
- import static org .assertj .core .api .Assertions .assertThat ;
19
-
20
18
21
19
@ WebMvcTest ({IndexController .class })
22
- @ Import ({IndexController .class , JsonCatalog . class })
20
+ @ Import ({IndexController .class })
23
21
@ ContextConfiguration (classes = {
24
22
MessageSourceConfig .class ,
25
23
WebMvcConfigurerConfig .class
You can’t perform that action at this time.
0 commit comments