Category Archives: Uncategorized

Multi-site / Multi-languages with Sitecore

My current client has a number of domains for various regions and some regions will support multiple languages, including Right-to-Left languages such as Arabic. So let’s highlight what needs to be done in Sitecore and our code to allow for this requirement.

Web.Config

Sites Node

Above you can see that we have 3 sites defined. The .com site has en as the default language, the .co.uk has en-GB and the .ae has ar-EG (arabic egyption). The next section goes over language fallback, but for now notice that .co.uk and .ae have a fallback to english.

Langugage Fallback

Alex Shyba who works for Sitecore has contributed a nice Shared Source module called Partial Language Fallback that allows Sitecore to fallback to a different language for an item or field if there is not a value available within the current language context. Alex goes into more detail about this module on his blog located here: http://sitecoreblog.alexshyba.com/2011/08/partial-language-fallback-module-update.html

Multiple Languages

The client’s requirement is that the .ae site should default to arabic but allow the user to choose english if they prefer. We already set the default language to arabic in our web.config above, so we have that covered but now we need the ability to set a site’s supported languages.

Site Languages

Above I have updated the Website Root template, which is the root template of each site item in my solution. We have added a Site_Languages treelist field that has the System/Languages as the source. This allows for the content authors to select which languages they want supported for each site.

Site Languages 2

Changing Languages

Now that the backend is setup, we can create a control that can be used in the site’s footer to appear when 2 or more languages for the site is available and allow the user to select a different language.

LanguageContext.ascx

Language Context

Our frontend code above is simply building out a dropdown list that is bound to the languages and it is adding a “selected” tag to the language that matches the current context.

LanguageContext.ascx.cs

Language Context 2

The ManageLanguages function is in charge of binding the repeater to the available languages and it only shows the repeater if there are 2 or more languages available. So in our .com and .co.uk sites this control will not be displayed but it will show up on the .ae site.

If the request is a PostBack, then it will set the language context for the user and then redirect to the original url to ensure the page and any controls loaded before this point are aware of the context change.

site.js

Then the last piece is simply to wire up the select box to submit the form on value change.

Right-to-Left Support

Still in proof of concept mode on this one but what I have so far to support right to left languages is to check to see if the current language context is right to left and if it is then swap out the style sheet with a different one. I will post an update if this approach changes after our UI developers take a look at it.

Right to Left

Run Forrest!!!

It is no secret, I really hate running. It is merely convenient. I would much rather play a game of basketball or better yet a game of lacrosse with some friends but doing so would require a lot of coordination with other people’s schedule and getting a court or field available. Not to mention you would then have to drive to the location. With running, I am only dependent on me, I choose the day and time and then it is just the matter of opening up the front door and making my legs alternate steps in a faster than a walk pattern. It is this convenience that actually makes running even less enjoyable. Only having to worry about your schedule and running by yourself is one of the reasons running is such a bore. The motivation isn’t there. If your body tells you that today is just too hectic and “tomorrow” fits into your schedule better, you will usually listen because you are only competing with yourself.

When you are playing a team sport or even an individual sport against an opponent such as tennis, you usually tune out your whiny body about how tired it is until after the play is over and then you tell it to be quiet because another play is starting. With running, it is just you and your body and your body is really loud and persistent about how much better it would be to cut this run in half and go home and watch SportsCenter.

Enter Nike+
Nike Plus

Nike+ allows you to turn running into more of a team and social activity while still maintaining the convenience. It has some cool things in terms of setting goals and tracking your runs but the nice thing that adds a bit more motivation are the Challenges. You can join hundreds of public challenges or you can create your own and try to build up some friendly competition and interaction with some friends and co-workers. Being in a fairly large company with multiple offices can make it difficult to connect with co-workers, especially if they work in a different state or country.

I setup a few challenges on Nike+ and invited my co-workers to run with me. I had a novice entry for those new to running or just wanted to get out there and walk for a bit a few times a week. I created a little more of a competitive challenge that has participants race to 75 miles within a month and then to foster some inter-office pride, I created the iCrossing Office Challenge. The Office Challenge had members represent their office in which every run contributes to the office they belong to and the office with the most miles at the end of every month wins.

Nike Plus Challenge

There is a nice Twitter like feed that shows the latest runs and by whom as well as a spot to do some Trash Talk or some friendly words of encouragement. I still hate running and my body still tries to make excuses to prevent me from running or to end my run early, but having Nike+ and the social aspect of the challenges allows me to yell back at my body “we need to de-thrown the Dallas Office once and for all”.

So get out there and try it. It works with a number of devices and if you have no friends you can always request me and I will run with you. My Nike+ ID is TeckChavez.

Starting…. Now!

 

One of my favorite posters at despair.com – if you haven’t gone there I highly recommend it. I have always joked “Don’t Wait, Procrastinate Now”, but I think it is now time to get serious and share some insights and thoughts around improving one’s life, relationships, time management and overall work efficiencies.