From 533582534f508bdbc76bc37e5e8524cb37f8497d Mon Sep 17 00:00:00 2001 From: usbharu Date: Mon, 26 Aug 2024 17:47:41 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20messages=E3=82=92=E3=83=9B=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=83=AA=E3=83=AD=E3=83=BC=E3=83=89=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/config/MessageSourceConfig.kt | 28 +++++++++++++++++++ .../src/main/resources/application-dev.yml | 3 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/MessageSourceConfig.kt diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/MessageSourceConfig.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/MessageSourceConfig.kt new file mode 100644 index 00000000..846d89ca --- /dev/null +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/MessageSourceConfig.kt @@ -0,0 +1,28 @@ +package dev.usbharu.hideout.core.config + +import org.springframework.boot.autoconfigure.context.MessageSourceProperties +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.context.MessageSource +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Profile +import org.springframework.context.support.ReloadableResourceBundleMessageSource + +@Configuration +@Profile("dev") +class MessageSourceConfig { + @Bean + fun messageSource(messageSourceProperties: MessageSourceProperties): MessageSource { + val reloadableResourceBundleMessageSource = ReloadableResourceBundleMessageSource() + reloadableResourceBundleMessageSource.setBasename("classpath:" + messageSourceProperties.basename) + reloadableResourceBundleMessageSource.setCacheSeconds(0) + return reloadableResourceBundleMessageSource + } + + @Bean + @Profile("dev") + @ConfigurationProperties(prefix = "spring.messages") + fun messageSourceProperties(): MessageSourceProperties { + return MessageSourceProperties() + } +} \ No newline at end of file diff --git a/hideout-core/src/main/resources/application-dev.yml b/hideout-core/src/main/resources/application-dev.yml index a6d4118b..2c19a35e 100644 --- a/hideout-core/src/main/resources/application-dev.yml +++ b/hideout-core/src/main/resources/application-dev.yml @@ -29,7 +29,8 @@ spring: virtual: enabled: true messages: - basename: messages.hideout-web-messages + basename: messages/hideout-web-messages + cache-duration: -1 thymeleaf: cache: false server: