Translations through the API - General Discussions - General Discussions - Progress Community
 General Discussions

Translations through the API

  • Translations through the API
  • Does anyone have a sample of how I could

    1) Figure out if a taxonomy\label has a translation for a specific culture

    2) Programmatically add the translation for said culture.

    Can be done in the API, yeah?
  • Hi,

    Please refer to the below sample where I have implemented getting the first flat taxonomy that does not have Bulgarian translation and adding the translation to it:

    var taxonomyManager = TaxonomyManager.GetManager();
     
    var taxonomy = taxonomyManager.GetTaxa<FlatTaxon>().Select(t => new
        
            Taxon = t,
            AvailableLanguages = t.AvailableLanguages
        )
    .Where(t => !t.AvailableLanguages.Contains("bg"))
    .Select(t => t.Taxon)
    .FirstOrDefault();
     
    taxonomy.SetString("Title", taxonomy.Title + "BG", "bg");
     
    taxonomyManager.SaveChanges();

    The third parameter (which is optinal) of the SetString extension method specifies on which culture the changes should be made through the culture name. Please keep in mind that the following namespace has to be included in order to use the SetString extension method:

    using Telerik.Sitefinity.Model;

    Regards,
    Velizar Bishurov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items