#1463 inprogress
Loïc

Any code in routes file break internationalization

Reported by Loïc | March 12th, 2012 @ 06:19 PM | in 1.4.x

Framework version: Play 1.2.4

Platform you're using: Ubuntu 11.10 + Last openJDK 6 (6b23)

Reproduction steps: The possibilities to run code and define variables in the routes file seem to break the internationalization system.

Example: If I run any kind of code in the routes file with the %{ }% syntax, all localized messages are broken. Only their properties keys are shown in the template.

For example in the message file (conf/messages.fr), if back.key=Retour is defined, only the key back.key is shown in the template. The translation is not loaded anymore.

If I delete the code in the routes file, all is OK.

Comments and changes to this ticket

  • Guylian Pot

    Guylian Pot April 30th, 2014 @ 01:37 PM

    I have this same issue on version 1.2.5.3 and didn't see any fixed bugs for this issue in 1.3. I hope commenting on it will bump it into the view of developers, because I think it's quite a dealbreaker.

    I haven't traced this problem down all the way yet, but it is safe to assume that things go wrong somewhere in the template parsing code, since that is the difference between a route file with and without code.

    My bet would be on GroovyTemplate.java, around line 213, that the Messages internals aren't initialized yet by the MessagesPlugin.

  • Alex

    Alex July 23rd, 2014 @ 09:45 AM

    • Assigned user set to “Alex”

    I will have a look, just to be curious, what kind of code did you put in the routes file?

  • Guylian Pot

    Guylian Pot July 23rd, 2014 @ 11:45 AM

    Simple if statements that check if certain modules are available or not so I don't have to delete / add routes when I tailor my basic application for a project. A simple version that could be made with the standard secure module would be:

    GET      /                  Application.index
    
    #{if play.modules.containsKey("Secure")}
    GET     /login              module:Secure
    #{/if}
    

    This way I can add or delete the secure module from the dependencies without getting warnings or errors.

  • Alex

    Alex August 1st, 2014 @ 09:31 AM

    I just tried with the 1.3.x version, and I didn't saw this problem. Can I see it just by adding the code sample you put in the previsous comment?

    #{if play.modules.containsKey("Secure")}
    GET     /login              module:Secure
    #{/if}
    

    if not could you provide an example (you can attached it to the issue)?

    Thanks

  • Guylian Pot

    Guylian Pot August 4th, 2014 @ 08:03 AM

    I probably should have tested if my simplified case showed the same symptoms... I can't seem to reproduce it with a clean application either, but in my project simply removing and adding those lines does have this huge impact.
    I'll try to see if I can figure out what setup is causing it, perhaps it is some timing issue that only happens on bigger applications or something.

  • Alex

    Alex August 4th, 2014 @ 11:47 AM

    • State changed from “new” to “inprogress”

    I also try in a bigger application,and I didn't spot any problem. Maybe problems can be related with some modules, or ...
    So I let you try to extract an example with the problem or have some more details about how to reproduce it.

    Thanks

  • Guylian Pot

    Guylian Pot August 4th, 2014 @ 01:47 PM

    Oke, by taking my project and stripping it down, I've found a setup that at least shows the symptoms at first load (use play run, navigate to localhost:9080 and it will show two labels like 'helpTitle', subsequent refreshes will show the correct value like 'Help'): https://github.com/gpgekko/PlayRoutesMessagesTest.

  • Alex

    Alex September 3rd, 2014 @ 07:04 AM

    • Milestone set to 1.3

    Ok I can see the problem with your code. I will have a look. thanks

  • Alex

    Alex January 14th, 2015 @ 06:39 AM

    • Milestone changed from 1.3 to 1.4.x

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2>Play framework</h2>

Play makes it easier to build Web applications with Java. It is a clean alternative to bloated Enterprise Java stacks. It focuses on developer productivity and targets RESTful architectures. Learn more on the <a href="http://www.playframework.org">http://www.playframework.org</a> website.<br><br>

<h2>Source code is hosted on github</h2>Check out our repository at <a href="http://github.com/playframework/play">http://github.com/playframework/play</a><br><br>

<h2>Contributing, creating a patch</h2> Please read the <a href="http://play.lighthouseapp.com/projects/57987/contributor-guide">contributor guide</a><br><br>

<h2>Reporting Security Vulnerabilities</h2> Since all bug reports are public, please report any security vulnerability directly to <em>guillaume dot bort at gmail dot com</em>.<br><br>

<h2>Creating a bug report</h2> Bug reports are incredibly helpful, so take time to report bugs and request features in our ticket tracker. We’re always grateful for patches to Play’s code. Indeed, bug reports with attached patches will get fixed far quickly than those without any.<br><br>

Please include as much relevant information as possible including the exact framework version you're using and a code snippet that reproduces the problem.<br><br>

Don't have too much expectations. Unless the bug is really a serious "everything is broken" thing, you're creating a ticket to start a discussion. Having a patch (or a branch on Github we can pull from) is better, but then again we'll only pull high quality branches that make sense to be in the core of Play.

Pages