Translate your Umbraco dictionary using an AI translation service
If you ever build a multilingual site for Umbraco then you'll know about the Dictionary. It's the place in Umbraco where you can create a "kind-of" multilingual key/value store for all the odd words and phrases you might want translating.
It's not really changed much across many incarnations of Umbraco and, whilst it works, it can be a little awkward to populate. You have to edit each item individually and then it requires you to provide translations for each item. I recently build a site that has 27 different languages and around 150 dictionary keys - that means a translator needs to provide over 4000 different translations and then an editor needs to populate them all. It's a long-winded, tedious task and can be quite error prone, too. So this got me to thinking... There has to be a better way!
The Better Way
I'd played around with Microsoft Azure Cognitive Services for various tasks before - such as providing text analysis, generating summaries and sentiment analysis. But I also knew Microsoft offered their own AI-powered translation service, Microsoft Translator. Now, there used to be a time when automated translation services where pretty poor - they just couldn't handle the nuances of "real" speech and fell flat. But a lot has changed, and now you'd be hard pressed to notice the difference between an AI translation and a professional human. So my thought was...
"What if we could use an AI translation service to automatically translate all the empty Dictionary items in Umbraco?"
Luckily, Umbraco is very extensible and I knew it was something I could build, so I built a quick proof of concept and then set-about building a package. I decided to build the package for the (at this time) spanking new Umbraco 10 - running on .NET 6. Mainly because I wanted to play around with the latest Umbraco but also to help me learn more about .NET Core.
Introducing... Diplo. Translator
"This is a package for Umbraco 10 CMS that adds a Translate option to the Umbraco Dictionary within the Translation tree. This option can be used to automatically translate all the empty dictionary items in the tree from the selected language using an AI-based translation service. By default this is Microsoft Translator. In future other providers may be supported."
It's pretty simple to use. After installation and configuration you just select the language you want to translate from (which defaults to your default language) and then click the "Translate" button. It will then go through every dictionary item that doesn't have a translation and translate it using the Microsoft Translator API. You can see an example of the dialog below:
The nice thing about Microsoft Translator is that it's easy to set-up if you already have an Azure Portal account. And you can just use the free level, which gives you a very generous, "2M chars of any combination of standard translation and custom training free per month". Given that most dictionary values are quite short then it won't cost most people anything to use.
I built a quick demo which I created a video from. It's of an older build, but it should give you an idea of how it works and how quickly it can churn through translations:
Where can I get it?
Like all my packages it is free to use and open-source. The easiest way to use it is to install from NuGet:
dotnet add package Diplo.Translator
Our Umbraco: https://our.umbraco.com/packages/backoffice-extensions/diplo-translator/
Source Code: https://github.com/DanDiplo/Diplo.Translator