cancel
Showing results for 
Search instead for 
Did you mean: 

Internationalization template strings

ribz33
Champ on-the-rise
Champ on-the-rise
hi,

how i can make a freemarker template multilingual ?

Im using template for dashlet and i want to internationalize it how i can do it ?

i had trieed this :
 ${message(product_name)}
for instance but its not working.
14 REPLIES 14

kevinr
Star Contributor
Star Contributor
Something like this should work:

${message("product_name")}
note the quotes around the I18N message string name.

The Templating engine executes with the repository context - so it does not have access to the webclient.properties I18N message bundle. Instead it only has access to the registered repository bundles as defined here:
config/alfresco/core-services-context.xml
in this section

    <!–                        –>
    <!– I18N                   –>
    <!–                        –>

    <bean id="resourceBundles" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
       <property name="resourceBundles">
          <list>
             <value>alfresco.messages.system-messages</value>
             <value>alfresco.messages.dictionary-messages</value>
             <value>alfresco.messages.version-service</value>
             <value>alfresco.messages.permissions-service</value>
             <value>alfresco.messages.content-service</value>
             <value>alfresco.messages.coci-service</value>
             <value>alfresco.messages.template-service</value>
             <value>alfresco.messages.lock-service</value>
             <value>alfresco.messages.patch-service</value>
             <value>alfresco.messages.schema-update</value>
             <value>alfresco.messages.webdav-messages</value>
             <value>alfresco.messages.copy-service</value>
          </list>
       </property>
    </bean>

So you can add your message bundle to this list using the extension mechanism if you don't want to edit the original file.

Thanks,

Kevin

ribz33
Champ on-the-rise
Champ on-the-rise
Thx a lot its very clear Smiley Very Happy

ribz33
Champ on-the-rise
Champ on-the-rise
Ok its working well, i have just a little bug on dashboard !

After connect, template in dashlet don't use right language, but if i refresh page i see good one.

I see always French language on connect although i choose English in login box. If i clic on my Alfresco, page is refreshed and i see English in dashlet.

If you know why im interested in.

kevinr
Star Contributor
Star Contributor
That does sound like a bug - please raise it in JIRA.

Thanks,

Kevin

ribz33
Champ on-the-rise
Champ on-the-rise
Ok, ticket is done :
http://issues.alfresco.com/browse/AWC-1038

thx Kevin

zummy
Champ in-the-making
Champ in-the-making
Hi Kevin,

I'm a newbie and there are things I'm still do not fully understand.

For a custom action I have added I would like to setup a label-id. So I've done the following:

- create a custom-services-context.xml in alfresco/extension with the following:
<beans>
    <bean id="resourceBundles" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
       <property name="resourceBundles">
          <list>
             <value>alfresco.messages.webclient-custom</value>
          </list>
       </property>
    </bean>
</beans>

- add a new webclient-custom.properties file in alfresco/messages

But it does not work. When I re-launch the jBoss server it raises tons of errors. What's wrong with that?

Thks in advance,
Christophe

ribz33
Champ on-the-rise
Champ on-the-rise
try this maybe :


    <bean id="resourceBundles" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
       <property name="resourceBundles">
          <list>
             <value>alfresco.messages.webclient-custom</value>

             <value>alfresco.messages.system-messages</value>
             <value>alfresco.messages.dictionary-messages</value>
             <value>alfresco.messages.version-service</value>
             <value>alfresco.messages.permissions-service</value>
             <value>alfresco.messages.content-service</value>
             <value>alfresco.messages.coci-service</value>
             <value>alfresco.messages.template-service</value>
             <value>alfresco.messages.lock-service</value>
             <value>alfresco.messages.patch-service</value>
             <value>alfresco.messages.schema-update</value>
             <value>alfresco.messages.webdav-messages</value>
             <value>alfresco.messages.copy-service</value>
          </list>
       </property>
    </bean>

me its working like this

zummy
Champ in-the-making
Champ in-the-making
Hi ribz33,

I've done what you say and now the server starts correctly. Thks. But on the other hand, Alfresco doesn't seem to find out the resource bundle. I'm running on jBoss server and I've put the properties file in C:\alfresco\jboss\server\default\conf\alfresco\messages

Is it the right place to put this file? I thought this directory was in the classpath…

Sorry for all these stupid questions. Thanks again.
Christophe

ribz33
Champ on-the-rise
Champ on-the-rise
i think that would be good…
maybe try to move your properties file to extension

C:\alfresco\jboss\server\default\conf\alfresco\extension
dont forget to change :
<value>alfresco.extension.webclient-custom</value>

where you want to use this properties ? in a jsp ?
In this case you need to load bundle like it in your jsp code:
<f:loadBundle basename="alfresco.messages.webclient-custom" var="myMsg"/>