Thursday, February 10, 2011

Lync Conversation Translator

I'm currently doing consulting for a multi-national company with offices where the primary language spoken is not English. The entire company are big users of Communicator/Lync, so I often find myself IM'ing with people who don't speak English. For the longest time, I would type my conversation into Google Translate, hit Translate, copy the results into my conversation window and press Enter. I would have to do the same for incoming IMs as well.  Conversations were slow and inefficient.  I would often think there HAS to be a better way to do this.

Thankfully, there is a basically FREE way to incorporate a conversation translator directly into Lync.  The Lync SDK includes a number of samples you can compile so you can learn the ins-and-outs of programming in Lync.  One of those samples just happens to be a Conversation Translator.  Even though I'm not a programmer (although I did somehow manage to pull off the Lync Dialing Rule Optimizer), I figured I'd try my hand at some Lync programming.


The Lync conversation translator is a Silverlight-based program that pops out alongside of your normal conversation window.  It uses Bing Translate as the backbone of the program, so all the translation happens "in the cloud" instead of putting a load on your servers.

I downloaded and installed the prerequisites (which included Visual Studio 2010) and then the Lync SDK.  Once the SDK is installed, the Conversation Translator source code can be found in %ProgramFiles(x86)%\Microsoft Lync\SDK\Samples\ConversationTranslator. There is a very helpful Readme.txt file that explains how to make the program work.

Being a complet n00b when it comes to anything other than Visual Basic, I was prepared for pain. I was amazed at how easy it was. First, you should copy the entire ConversationTranslator folder to a different spot on your hard drive (like your Documents folder).  If you don't then you will run into permissions issues when trying to make changes to the Program Files folder structure.  Then, simply double-click the Visual C# project file ConversationTranslator.csproj file.  It should open the project in Visual Studio.  Click on the menu header Build and then click Build ConversationTranslator.  In a second or so, the build should be complete.  The compiled program will be created in the ConversationTranslator\Bin\Debug folder.

To test out the program to make sure it compiled correctly, open Lync, and have a single conversation open. Double-click the ConversationTranslatorTestPage.html file. A web page should open that will show the source language and the language you want to translate to.  Type something into the window, press Translate (or press Enter), review the translated phrase and then press Send (or Enter).  Incoming IMs will be translated back to your native language.

Once you've confirmed the program compiled correctly, copy the entire contents of the ConversationTranslator\Bin\Debug folder to either a file share or a website.  I prefer using a website, because the translator will work for both internal and external users, although there's nothing stopping you from using a file server internally, and a website externally.

Included in the Conversation Translator sample are a number of customizable registry files.  These registry files are all that's required on the client to enable the Conversation Translator feature. The registry file basically points the client to the location where you copied the ConversationTranslator files (either a file share or a website).  There's a sample file for local, fileshare and web deployments.  The only caveat for using the web version is that the site where you host the files must be in the Trusted Sites IE zone.  Thankfully, the sample includes the required registry setting for adding the website to that zone.

Modify the .reg file and deploy as you see fit.  Here's what the sample .reg file for a web deployment looks like:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Communicator\ContextPackages\{69380005-8401-414c-9a8b-dea88e3ffb71}]
"Name"="Conversation Translator"
"ExtensibilityApplicationType"=dword:00000000
"ExtensibilityWindowSize"=dword:00000001
"DefaultContextPackage"=dword:00000000
"InternalURL"=http://www.contoso.com/folder/ConversationTranslatorTestPage.html
"ExternalURL"=http://www.contoso.com/folder/ConversationTranslatorTestPage.html

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\contoso.com\www]
"http"=dword:00000002
When everything is working, when you are conversing with someone, just click the little options arrows and select Conversation Translator.

A new nicely integrated conversation window will appear. Select from any of 32+ different languages as your source and destination and start typing away!


This program has allowed me to realize my lifelong dream of being able to insult someone in Italian, just like Ricky in I Love Lucy.

I've made a few minor alterations to the program to make it a little more intuitive. By editing the MainPage.xaml.cs, I changed the error message for when the website isn't in the Trusted Sites IE zone to actually state what site to add to the zone, rather than the generic one included.  I also changed the program so that the original, pre-translated IM is shown in the Translation window, instead of the translated text as in the default sample, which makes it easier to read when you don't understand the language you're translating to. 

I'm also trying to figure out how to write the source language text into Outlook's Conversation History, instead of the translated text, which makes it difficult to understand after the fact.  There is also a minor issue with long lines of text not being displayed properly in the translation window.

Those few minor quibbles aside, the Conversation Translator included with the Lync SDK is an amazing FREE (did I mention its FREE?) tool you can add to your deployments with minimal fuss.

UPDATE (March 29, 2011): I've seen more than a few blogs post a .REG file that points to a Conversation Translator source on Microsoft's network ("http://input.microsoft.com/translator/OCTranslatorTestPage.html").  I was told as recently as January that this source was to be kept private and was for demo use only. However, now that even a Technet blog has posted this, I'm assuming Microsoft is letting this out in the wild.

So, instead of having to compile the sample yourself, you can simply use the Microsoft URL for InternalURL and ExternalURL.

UPDATE (May 31, 2013): There is an updated regkey for Lync 2013.  Check out VOIPNorm's blog post on the subject, rather than going through the whole process of compiling it yourself.  http://voipnorm.blogspot.ca/2012/11/lync-2013-enabling-conversation.html