Search code examples
internationalizationspring-bootthymeleafspring-cloudnetflix-zuul

Spring Cloud breaks i18n messages


I have a spring boot Thymeleaf web application with internationalised messages. The default translations are in my messages.properties file.

My application.yml directs the MessageSourceAutoConfiguration to these messages:

spring:
 messages:
  basename: locale/messages

When I run the app, a breakpoint in MessageSourceAutoConfiguration.setBasename() is hit with the argument locale/messages, and everything works beautifully.

Now I want to use Zuul to set use this application as a reverse proxy to pass requests through from the browser to a REST application.

import org.springframework.cloud.netflix.zuul.EnableZuulProxy;

@SpringBootApplication
@EnableZuulProxy
public class ThymeleafApplication extends SpringBootServletInitializer {
    ...
}

So I add some config to my application.yml:

zuul:
 routes:
  rest-api:
   path: /rest-api/**
   url: https://localhost:443/my-rest-api

and my build.gradle looks like this:

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
    compile 'org.springframework.cloud:spring-cloud-starter-zuul:1.0.4.RELEASE'
}

The reverse proxy now works correctly, but the internationalisation is broken. Messages are displayed as '??page1.message1_en_GB??'. The breakpoint in MessageSourceAutoConfiguration.setBasename() is no longer triggered.

How can I set up Zuul so that my i18n still works?


Solution

  • Okay, I've fixed this by upgrading to the latest version of Spring Boot, 1.3.1.RELEASE.

    It was a bug as pointed out in @nerdherd's answer to a similar question.