Skip to content

Commit

Permalink
Use application message source
Browse files Browse the repository at this point in the history
  • Loading branch information
UweKubosch committed Jan 27, 2023
1 parent 994f469 commit 2a288c8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ https://github.com/DatekWireless/slim-spring-webmvc
* https://s01.oss.sonatype.org/
* https://s01.oss.sonatype.org/content/repositories/releases/no/datek/
* https://search.maven.org/
* https://search.maven.org/search?q=slim-spring-webmvc
* https://search.maven.org/search?q=slim-spring-webmvc

## Release to Maven Central

* Bump the version in build.gradle
*
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'no.datek'
version '0.0.9'
version '0.1.0'

java {
withJavadocJar()
Expand Down
12 changes: 0 additions & 12 deletions src/main/resources/ruby/controller_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,4 @@ def current_locale(request)
end
locale
end

@@message_source = Java::org.springframework.context.support::ReloadableResourceBundleMessageSource.new
@@message_source.setCacheSeconds(300)
@@message_source.setBasenames("classpath:lights_version", "classpath:lightsMessages")

def message_source
@@message_source
end

def message_source_accessor(locale)
MessageSourceAccessor.new(message_source, locale)
end
end
8 changes: 6 additions & 2 deletions src/main/resources/ruby/slim_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,20 @@ def params.[](key)
super(key.to_s)
end

application_context = rendering_context.application_context
message_source = application_context.get_bean(org.springframework.context.MessageSource.java_class)
message_source_accessor = MessageSourceAccessor.new(message_source, locale)

default_context = {
_csrf: request.getAttribute('_csrf'),
application_context: rendering_context.application_context,
application_context: application_context,
content_store: {},
ctx: request.contextPath,
current_location: request.getSession().getAttribute("currentLocation"),
currentLocation: request.getSession().getAttribute("currentLocation"),
current_user: SecurityContextHolder.context&.authentication&.principal,
locale: locale,
message: message_source_accessor(locale),
message: message_source_accessor,
messages: message_source,
messageSource: message_source,
message_source: message_source,
Expand Down

0 comments on commit 2a288c8

Please sign in to comment.