We are using the code below to make translation branch for a page. Need help to make translation branch for block.
The idea is to programmatically translate pages and all the nested blocks automatically, for now we just need copied content and not the actual translation.
var xyz = startpageLanguageBranch.HeaderBlock; foreach (var element in xyz.Items) { var b = element.ContentLink.ID; var tobecopied = new ContentReference(b);
var startpagelanguagebranch1 = contentRepository.CreateLanguageBranch<HeaderBlock>(tobecopied, new LanguageSelector("sv"));
var id = currentPage.ContentLink.ID;
var parent = new ContentReference(id);
IContentRepository contentRepository =
EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentRepository>();
var startpageLanguageBranch =
contentRepository.CreateLanguageBranch<HeaderBackgroundPage>(parent,
new LanguageSelector("sv"));
startpageLanguageBranch.PageName = "Start page test uk";
startpageLanguageBranch.Title = "Start page test uk";
startpageLanguageBranch.BackgroundImage = currentPage.BackgroundImage;
contentRepository.Save(startpageLanguageBranch,
EPiServer.DataAccess.SaveAction.Publish,
AccessLevel.NoAccess);
var xyz = startpageLanguageBranch.HeaderBlock;
foreach (var element in xyz.Items)
{
var b = element.ContentLink.ID;
var tobecopied = new ContentReference(b);
var startpagelanguagebranch1 =
contentRepository.CreateLanguageBranch<HeaderBlock>(tobecopied, new LanguageSelector("sv"));
contentRepository.Save(startpagelanguagebranch1, EPiServer.DataAccess.SaveAction.Publish, AccessLevel.NoAccess);
}
startpageLanguageBranch.HeaderBlock = currentPage.HeaderBlock;
startpageLanguageBranch.ContainerSize = currentPage.ContainerSize;
contentRepository.Save(startpageLanguageBranch,
EPiServer.DataAccess.SaveAction.Publish,
AccessLevel.NoAccess);