cancel
Showing results for 
Search instead for 
Did you mean: 

Localization of page title in Surf

chozero
Champ in-the-making
Champ in-the-making
Hi,

I've seen it's easy to localize Surf components (http://wiki.alfresco.com/wiki/Web_Scripts#Message_Bundles), but is it possible to localize the title of a Surf page?

It would be something like:
<?xml version='1.0' encoding='UTF-8'?>
<page>
   <title>${msg("home")}</title>
   <template-instance>ib_base</template-instance>
   <authentication>none</authentication>
</page>

The "home" property would be in a .properties file, but where should it be deployed?

Thanks and greetings, chozero.
1 REPLY 1

chozero
Champ in-the-making
Champ in-the-making
Finally i could solve this taking a look at how Alfresco Share does. I don't know if everything is done the right way but now is working for me.

First i declared an additional resource bundle in webscript-framework-application-context.xml:

   <bean id="webscripts.resources" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
      <property name="resourceBundles">
         <list>
            <value>alfresco.messages.webscripts</value>
            [b]<value>alfresco.messages.mymessages</value>[/b]
         </list>
      </property>
   </bean>

The mymessages.properties file is in the extension classpath (at alfresco/messages) and contains the names of the pages and other strings.

The definition of the page.xml remains the same, with title-id declared, which is used as the key in the messages file:
<page>
   <id>home</id>
   <title>page.inicio</title>
   <title-id>page.inicio.title</title-id>
   <template-instance>ib_base</template-instance>
   <authentication>none</authentication>
</page>

At last, i changed the ftl template to display the localized title of the page (as seen in Share):

<head>
   ….
   <title>
      <#if page.titleId??>${(msg(page.titleId))!page.titleId}<#else>${page.title}</#if>
   </title>
   ….
</head>

Still have to learn lots of freemarker but i'm on the way Smiley Happy