2010
12.01

The setup

We need to provide different language versions of a site based on the language of the article, or perhaps the domain of the site. This relates to the static text of the design, and not the content itself, wich of course is already translated.

Implementation

To do this, we use the import <library> as <name> in Freemarker.

First we create 2 different libraries, ie. lib/translations-en and lib/translations-no, and assign our variables. We have to have the same variable names in both libraries.

Examples (norwegian):

<#assign home="Hjem"> 
<#assign here="Du er her"> 
<#assign by="av"> 
<#assign lastUpdated="sist oppdatert"> 

and english:

<#assign home="Home" > 
<#assign here="You are here" > 
<#assign by="by"> 
<#assign lastUpdated="last updated"> 

Then we import one of the libraries into our template, by using the switch directive:

<#switch fullHost>  
	<#case "http://dev.baltic-recruiting.lt">  
		<#import "lib/translations-lt" as langlib>  
		<#break>  
	<#default>  
		<#import "lib/translations-no" as langlib>  
</#switch>

 

This does the import by querying the fullHost, but you can also use data.language.

Now we can reference the translated strings by using ${langlib.<variable>}, for example ${langlib.home} to display the home string.

You can see this in effect by visiting www.baltic-recruiting.com and www.baltic-recruiting.lt

2010
12.01

About this blog

This blog is intended as a place where I can show of interesting things about the product I am currently the lead of, iSite, and also as my personal blog. Things I say here are of my own opinion, and is not in any way my employers opinion.

About iSite

iSite is a CMS system built entirely with IBM Lotus Domino as a backend. We use a lot of jQuery, and a lot of jQuery UI in the admin interfaces, and our publishing templates are built using Freemarker. iSite is currently in version 6, and approaching version 6.1.

About me

I have been consulting and programming solutions based on IBM Lotus software since 1997, and are very comfortable building modern webapplications on this platform. Besides IBM Lotus software, I have also been working a lot with other technology stacks, such as JEE, .Net and also Groovy+Grails.

About Workplace Consulting

Workplace Consulting is THE consulting company (remember, my opinions on this site!) for IBM Lotus, Websphere and Tivoli in norway, and I happen to be one of the lucky persons working there :)