Send for translation

The following code sample demonstrates how you can send programmatically items for translation. The sample send all News items for translation from English to German and French:

C#
using System;
using System.Globalization;
using System.Linq;
using Telerik.Sitefinity.GenericContent.Model;
using Telerik.Sitefinity.Modules.News;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Translations;

namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules
{
   public partial class TranslationsSnippets
   {
       public static void SendAllNewsForTranslation()
       {
           // Creates a translation project selecting the first connector 
           var projectInfo = new ProjectInfo(
                   "Translating News", // Title
                   DateTime.UtcNow, // Start date 
                   DateTime.UtcNow.AddDays(5), // Due date
                   "Translating all news from EN to FR and DE", // Description
                   TranslationService.Current.Connectors.First().Name, // connector name
                   string.Empty, // PO reference
                   string.Empty); // the actual language of the source                   

           // Get a list of news items for translation
           var newsManager = NewsManager.GetManager();
           var newsItemsToTranslate = newsManager.GetNewsItems().Where(i => i.Status == ContentLifecycleStatus.Master);

           // Send the items to the translation agency
           TranslationService.Current.SendForTranslation(
               newsItemsToTranslate,
               SystemManager.CurrentContext.AppSettings.GetCultureByName("en"),
               new CultureInfo[] { SystemManager.CurrentContext.AppSettings.GetCultureByName("fr"), SystemManager.CurrentContext.AppSettings.GetCultureByName("de") },
               projectInfo);
       }
   }
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
New to Sitefinity?