AnsweredAssumed Answered

Freemarker locale aware in surf, not in webscripts

Question asked by loftux Moderator on May 13, 2011
Latest reply on Dec 8, 2011 by tullo
This is a problem that has surfaced using the site-blog dashlet from share-extras, using an older version that does not use client side requests, all server side.

When doing a blog post listing in the dashlet, in Share it does a remote connector request to alfresco
theUrl = '/api/blog/site/' + site + '/' + container + '/posts?pageSize=10';

This returns a json, date snippet
# modifiedOn: "May 13 2011 14:19:13 GMT+0200 (CEST)"
On the server, locale is en_US. Freemarker has formatted the date as per the locale

Now the problem.
In Share, now Freemarker has to format this for output
${msg("text.modified-on", post.createdOn?datetime("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")?string("d MMM, yyyy HH:mm:ss"))}

But as it turns out, Freemarker in Surf is locale aware. So if my web browser preference locale is sv_SE, Freemarker expects the date in format
"Maj 13 2011 14:19:13 GMT+0200 (CEST)" ->Notice the different spelling for May/Maj.  Thus it cannot detect as date and fails. Switching to a web browser with en_US, and all is good again.

Now, since in surf there is a root object locale, can I pass this on to alfresco webscripts so that I get correctly formatted dates?
I've tried hitting the alfresco/s/api/blog/site/{sitename}/{container}/posts webscripts directly with different browser locales, but it always returns english formatted dates.

Can you change the locale during processing? Probably would change the msg bundle output if possible, so maybe not the best option.