cancel
Showing results for 
Search instead for 
Did you mean: 

How to I18N FTL date display ?

yva
Champ in-the-making
Champ in-the-making
Hi,

I am working with alfresco 3.2r2

How to internationalize the display of a date within à freemarker template ?

In the following code sample
the ${child.properties["cm:created"]?datetime} code
always displays the date in the same language,
whatever the user language preferences of my user.

Has anybody any hint on which FTL code to use to internationalize
the display of the creation date of a document ?

Thanks in advance


<#– Table of docs in a specific folder, that have been created last 3 days –>
<h3>${template.properties.description}</h3>
<table cellpadding=2>
   <tr>
      <td></td>
      <td><b>${message("project.template.name")}</b></td>
      <td><b>${message("project.template.created")}</b></td>
   </tr>
   <#list space.childrenByXPath[".//*[subtypeOf('cm:content')]"]?sort_by(['properties','cm:name']) as child>
      <#if (dateCompare(child.properties["cm:created"], date, 1000*60*60*24*3) == 1) && (child.properties.name?ends_with(".pdf") )>
         <tr>
            <td><a href="/alfresco${child.url}" target="new">${child.properties.name}</a></td>
            <td>${child.properties["cm:created"]?datetime}</td>
          </tr>
      </#if>
   </#list>
</table>
3 REPLIES 3

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
message(String) - will return the I18N message string (resolved for current user Locale setting) for the specified String message ID.

${lastUpdated?string("yyyy-MM-dd HH:mm:ss zzzz")}
${lastUpdated?string("EEE, MMM d, ''yy")}
${lastUpdated?string("EEEE, MMMM dd, yyyy, hh:mm:ss a '('zzz')'")}


so you get message with format and then you format it.

yva
Champ in-the-making
Champ in-the-making
Thanks for your solution Savic,

so I will code

${child.properties["cm:created"]?string("dd-MM-yyyy HH:mm:ss")}

which won't introduce language related names of month

Thanks again

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
you can read about date formats hire http://www.exampledepot.com/egs/java.text/FormatDate.html