Results 1 to 2 of 2

Thread: Thymeleaf isn't resolving localized messages

Threaded View

  1. #1
    Join Date
    Nov 2009
    Location
    Montreal, Quebec
    Posts
    398

    Default Thymeleaf isn't resolving localized messages

    I created an app with Roo and ran the "web mvc setup" command. I'm deleting the actual JSP views and tiles setup, etc as I'm replacing that with Thymeleaf.

    This line is the default that Roo generates for a MessageSource and I've added some entries to WEB-INF/i18n/messages.properties, but they're not being picked up.
    Code:
    <bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource" p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application" p:fallbackToSystemLocale="false"/>
    Here is a fragment from my view which checks to see if a list is empty, declares a variable who's value is a localized message in messages.properties so that it's available in the template called "empty-table".
    Code:
    <div th:if="${#lists.isEmpty(activities)}" th:with="tableText=#{activities.noDataFound}">
        <table th:substituteby="templates/empty-table :: empty-table"/>
    </div>
    Here is my messages.properties
    Code:
    tables.noDataFound=No data found.
    
    activities.noDataFound=No activities found.
    When I run my app, the message #{activities.noDataFound} isn't resolved, instead I get "??activities.noDataFound_en_US??". If I look at the console output when I run jetty, I can see my MessageSource is picked up and it shows the basenames indicated in the bean config, so shouldn't my message get resolved?
    Last edited by pgrimard; Nov 30th, 2012 at 11:54 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •