Multi-lingual
Development

Mar 08

Introduction

When creating a multi-lingual site in Sitefinity it isn't just a matter of adding a language and creating the alternative content. To be truly multi-lingual there are many design considerations you need to consider. As a developer, one of your first considerations is how to set up multiple URLs so that your site will render in different languages.

In Sitefinity you have two options.
Use different domain names such as mysite.com and mysite.fr or you can have a language identifier inserted into your URL path. This results in mysite.com/en/page and mysite.com/fr/page.

The later option doesn't require you to do anything but the first requires you to set up multiple bindings.

Domain Names

First we need to decide on our local machine domain names. I am going with,
mysite.localhost.com
mysite.localhost.fr

We need to ensure our machine resolves these domains to our local machine and to do this we need to edit our machines host file.
C:\Windows\System32\drivers\etc\hosts if its been a while since you had to interact with this or if you are young.
Open with Notepad and remember the file has no file type extension and you may need to open it as an administrator on your machine. Resolve both domains to 127.0.0.1 which is always associated with the local machine.

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

127.0.0.1   mysite.localhost.com
127.0.0.1   mysite.localhost.fr

So that is an entire /8 network block reserved for your machine. That is 16,777,214 potential public IP addresses rendered unusable. Luckily we have IPv6 now... kind of.

There are generally two scenarios to deal with at this point. Those that use IIS and those that use IIS Express.

IIS

If you are using IIS then you have access to a GUI to bind the multiple URLs. Select your website and then find the bindings option to the right. You can then assign your URLs in the Host Name field keeping the same IP and port designations. IIS will then accept and send HTTP requests for both domains to your Sitefinity site.

IIS Bindings

IIS Express

IIS Express is a bit different as it doesn't come with a GUI like the full blown IIS and so you need to manually edit a file.

The file is a hidden file so you need to turn on show hidden files in your Explorer or you can just type the folder name directory. The folder is found in the same location as your .sln file and the folder is /.vs. From there browse to /.vs/configuration/applicationHost.config.

Application Host file location

Open this file in any editor and go and find the node. In the list you will find your site and the current port bound to the site. Copy that line and change localhost to 127.0.0.1.

Application Host File

Our Host file will resolve our domain names to the 127 IP address and we just need to ensure that IIS Express will accept and bind to the IP as well. I don't know why localhost which resolves to 127 doesn't work but I do know this is what you need to do. You should also consider committing this file to your source control so that the change can be persisted with the project.

Why use IIS Express?

I personally prefer IIS Express for the primary reason that if you use IIS then your IIS setup must match everyone else's set up. If you are a lone developer or even a small group its not a problem but in a large group I have seen the issue where a new developer downloads the project but the ports and file locations are different on his machine so they change it and check it in. Then people get latest and suddenly chaos breaks out. The result is usually everyone agreeing not to check in 'those' changes but it never really flies.
I like IIS Express as its relative to the project and is the same engine running full blown IIS.
There are other pros and cons but don't nothing to get in a fight about.

Your Project

We are almost done. Open up your project and the web tab. Then add in your default domain name so that when you start your debugging the url will be your selected choice.

Finally, use the same domain names in your Sitefinity language options.

There we go. Running a multi lingual Sitefinity site on your local development machine. Keep in mind about how you manage the configuration files as you of course do not want to push your local names out to other environments.


Darrin Robertson - Sitefinity Developer

Thanks for reading and feel free to comment - Darrin Robertson

If I was really helpful and you would buy me a coffee if you could, yay! You can.


Leave a comment
Load more comments

Make a Comment

recapcha code