Translations through the API

Posted by Community Admin on 03-Aug-2018 16:31

Translations through the API

All Replies

Posted by Community Admin on 17-Aug-2015 00:00

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?

Posted by Community Admin on 19-Aug-2015 00:00

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
 

This thread is closed