Try Now
More in this section

Forums / General Discussions / Translations through the API

Translations through the API

2 posts, 1 answered
  1. Steve
    Steve avatar
    3037 posts
    03 Dec 2008
    17 Aug 2015
    Link to this post

    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?
  2. Velizar Bishurov
    Velizar Bishurov avatar
    143 posts
    21 Oct 2016
    19 Aug 2015
    Link to this post

    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)
    taxonomy.SetString("Title", taxonomy.Title + "BG", "bg");

    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;

    Velizar Bishurov
    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
2 posts, 1 answered