Translating a block

Vote:
 
Hello, urgent assistance required.
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 startpagelanguagebranch1 =
                contentRepository.CreateLanguageBranch<PageType>(tobecopied,new LanguageSelector("sv"));
This is the code 


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);

Regards
Abdul Samad
#203385
Apr 19, 2019 13:47
Vote:
 

I'm not quite sure I understand where exactly is the issue..

#203390
Apr 21, 2019 19:18
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.