Play 2.6.2 Apostrophe not beeing rendered

87 views
Skip to first unread message

Sascha Thiel

unread,
Oct 30, 2017, 11:06:57 AM10/30/17
to Play Framework
Hey all, 

I've experienced the problem, that the apostrophe ' will not be rendered with messages.

Sample: See what's happening
Output: See whats happening

So the ' just gets removed. Does anybody have an idea how to make the ' beeing rendered?

Bests,
Sascha

Justin du coeur

unread,
Oct 31, 2017, 4:29:40 AM10/31/17
to play-fr...@googlegroups.com
This sort of thing is typically an HTML escaping problem.  (Since apostrophe is a legal quote delimiter, it's sensitive, and very easy to mess this up.)  Have you inspected the final HTML (in the browser webpage), to see what is actually in there?  In my experience, you generally have to work backwards, to figure out where the apostrophe is being mishandled...

--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/b0ad8f79-08ea-41f2-a605-10f29885bed2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sascha Thiel

unread,
Oct 31, 2017, 5:15:39 PM10/31/17
to Play Framework
Hey, 

Unfortunately it is not just an escaping thing. I debugged it and the call of 

messages.get(lang(),"key");

is returning the string already without the apostrophe. So it must be something different.

Thanks and Bests,
Sascha


Am Dienstag, 31. Oktober 2017 09:29:40 UTC+1 schrieb Justin du coeur:
This sort of thing is typically an HTML escaping problem.  (Since apostrophe is a legal quote delimiter, it's sensitive, and very easy to mess this up.)  Have you inspected the final HTML (in the browser webpage), to see what is actually in there?  In my experience, you generally have to work backwards, to figure out where the apostrophe is being mishandled...
On Mon, Oct 30, 2017 at 11:06 AM, Sascha Thiel <lino...@gmail.com> wrote:
Hey all, 

I've experienced the problem, that the apostrophe ' will not be rendered with messages.

Sample: See what's happening
Output: See whats happening

So the ' just gets removed. Does anybody have an idea how to make the ' beeing rendered?

Bests,
Sascha

--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.

Tim Moore

unread,
Oct 31, 2017, 6:45:42 PM10/31/17
to play-fr...@googlegroups.com
Hi Sascha,

The standard Java i18n resource bundle format requires escaping apostrophes by doubling them: https://docs.oracle.com/javase/8/docs/api/java/text/MessageFormat.html

Within a String, a pair of single quotes can be used to quote any arbitrary characters except single quotes. For example, pattern string "'{0}'" represents string "{0}", not a FormatElement. A single quote itself must be represented by doubled single quotes '' throughout a String.

Pretty confusing, but not a Play-specific issue. It is mentioned in the Play docs however: https://www.playframework.com/documentation/2.6.x/JavaI18N#Notes-on-apostrophes

Cheers,
Tim

To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/3c837886-1176-46bc-9094-f2a595553da1%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Tim Moore
Senior Engineer, Lagom, Lightbend, Inc.

Tonny Garić

unread,
Nov 1, 2017, 3:55:12 AM11/1/17
to Play Framework
Hi Sascha,

Are you using the Play Translations?

Because if you are, you can escape an apostrophe with two apostrophes.

Expected: what's
Use in code: what'''s


- Tonny Garić

Sascha Thiel

unread,
Nov 2, 2017, 3:00:27 AM11/2/17
to Play Framework
Thanks Tim and Tonny,

Escaping helped. I searched for the issue, but this page never showed up in my search results.

Bests,
Sascha
Reply all
Reply to author
Forward
0 new messages