Tuesday 22 April 2008

The sustainable enterprise (what is your company doing?)

I do not want to make a habit of doing semi-advertising on this blog, but I could not resist and let the coincendence pass by unnoticed.
Today being the international Earth Day and yesterday InterfaceFLOR, the company I work for, announced receiving a prestigious royal award in the UK for sustainability.
Led by our sustainability pioneer Ray Anderson, InterfaceFLOR are striving to be a fully sustainable enterprise by the year 2020 and the enthousiasm of this initiative is carried out by employees from the factory floor up to the board. And given the raw materials we use in our products are all based on oil, not an easy goal. But a goal well worth pursuing if we want to pass on a live-able earth to our children and grandchildren.
More on the sustainable efforts of InterfaceFLOR can be found here and here.

Thursday 17 April 2008

I am on Planet Lotus

Thanks to Yancy Lent, this blog now feeds into the Planet Lotus site. Now the task is mine to keep adding content here at a regular basis.
Although there is not much here yet it wil grow.
At the moment I think my focus when blogging will mainly be Lotus Notes / Domino development, but who knows, this may change in the future.

I really like how Planet Lotus works. I can follow almost all (and more) of the blogs I am interested in on one page. Not a day goes by without picking up an interesting topic. And as a result I now only have a few feeds left in my Google reader.

Wednesday 16 April 2008

I tweeked the default layout (a bit)

When setting up this blog I chose the standard available Demin Stretch. But I did not like the used colours in the sidebar header.
So I decided to make some changes to that and make it more in line with the rest of the colours used in this template. So here it is, a nice blue border.

And while I was at it, I also added some borders to the post headings and I added an image in the header reflecting my all time favorite hobby, kayaking.

Monday 14 April 2008

detecting language settings for a website using @formula

The company I work for is a multinational in Europe and their website, reflecting Europe, is multilingual. The main url for this website however directs to a general page for all of Europe and is in English. And you get it, soon the request came for the site to be able to detect where the visitor is coming from and redirect this visitor to his local language homepage if it is available.
After some discussion we decided to use the setting for browser language rather than using the some IP-detect to determine the preferred language of the visitor.
Initially I started using the @LanguagePreference, which given the name of the function would be the right one to use. And it did for a while, until we started rolling out the website to countries where more than one language is spoken. Like Belgium with french and dutch or Switzerland with german, french and italian.
In these countries we would like the visitors to be redirected to the homepages of that country in the preferred language of the user. And that is where @LanguagePreference starts to fail.
Lets take an example: A Belgian visitor would most likely set their preferred language to french or dutch (vlemish), respectively fr-be & nl-be in the browser.
But @LanguagePreference respectively returns "fr" and "nl". And thus we do not have enough information to route the visitor to the proper homepage and they are redirected to the french or dutch homepage.
As I do not know all the @functions by heart, I turned to our admin (Dennis), to see if this could be solved in our firewall. But instead of configuring the firewall he pointed me to the @GetHTTPHeader function and its HTTP_Accept_Language parameter.
As it turns out, this function nicely returns a string of the set languages as set in the browser. Although the browsers have their differences, the major ones are comparable when languages are defined for countries that have multiple languages.

So here is how it works:
When opening the default homepage, before processing the rest of the page, some @function code determines the visitors language and does a dblookup to see if a homepage exists in visitors browser defined language. If so, a meta refresh is set to re-direct the visitor to the local language homepage.

This is the code that is used:
(Underneath the second rem block a keyword is retrieved as the naming of the languages in the site is not always in line with what the browsers use and somtimes the browsers are not using the same language coding.)


REM {== get the languagesettings from the browser (retrieve the first setting in the list) ==};
brlang := @LowerCase(@Subset(@Explode(@GetHTTPHeader("Accept-Language"); ",");1));
brlang_2 := @Left(brlang; 2);

REM {== get the Languages Browser keyword for languages that differ between browser and site ==};
REM {== and replace if preflang is found in browserlangs ==};
lb := @LowerCase(@DbLookup("Notes" : "NoCache"; ""; "luKeywords"; "languages browser"; 2; [FailSilent]));
browserlangs := @Left(lb; "~~");
sitelangs := @Right(lb; "~~");
preflang:=
@If(
@IsMember(brlang; browserlangs);
@Subset(@Subset(sitelangs; @Member(brlang; browserlangs)); -1);
@IsMember(brlang_2; browserlangs);
@Subset(@Subset(sitelangs; @Member(brlang_2; browserlangs)); -1);
brlang_2
);

REM {== try to get indexpage for user browserlanguage ==};
key := "index_" + @UpperCase(preflang) + ".html";
page := @DbLookup("Notes":"NoCache";""; "webpages"; key; 1; [FailSilent]);

REM {== if path_info ends in /, remove it, so it compares better to dbPath ==};
pathinf :=
@If(
@Right(Path_Info; 1) = "/";
@Left(Path_Info; @Length(Path_Info)-1);
Path_Info
);
REM {== show default homepage when path in url is not blank or identical to dbpath or ==};
REM {== if language homepage for browserlanguage is not found ==};
REM {== else reroute to language homepage ==};
@If(
pathinf != "" & pathinf != dbPath;
"";
page = "";
"";
"<meta http-equiv=\"refresh\" content=\"0;url="+dbPath + "/webpages/" + page +" />"
)