Add translation to a Dynamic Content item
Hi all,
What would be the best way to create a multilingual Dynamic Content Item through code? I have a source table with some records that have both english and dutch translation which I need to import into a Dynamic Module. Can I do this at once?
I know how to add an item with a default culture. But how do I add the second culture in the same procedure?
Thanks,
Daniel
Hello Daniel,
I am attaching an approach for adding multilingual to the modules that are not hierarchical (NewsRoomArticles, NewsRoomDocuments), refer to the attached (ModuleBuilderLanguageVersionCreator.zip).
The form uses the approach from how hierarchical data items are created from NewsRoomGallery sample
Thread.CurrentThread.CurrentUICulture = enCulture;
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
Type testType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.NewsroomContent.NewsroomArticle");
//create the item in invarian culture
DynamicContent testItem = dynamicModuleManager.CreateDataItem(testType);
Guid itemId = testItem.Id;
//assign its values in specific culture and publish
using (new CultureRegion(enCulture))
testItem.SetString("Title", "Some Title", enCulture);
testItem.SetString("UrlName", "SomeUrlName", enCulture);
testItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Published", enCulture);
dynamicModuleManager.SaveChanges();
dynamicModuleManager.Lifecycle.Publish(testItem);
dynamicModuleManager.SaveChanges();
// perform the same for additional languages
I am also attaching a sample of Module Builder Language Version Creator. Hopefully this helps.
Please feel free to write back to me if you need further assistance.
Regards,
Anjeza Llapi
Telerik
Sitefinity Stanislav
[View:/cfs-file/__key/communityserver-discussions-components-files/296/d027811d_2D00_ddff_2D00_4540_2D00_8d9e_2D00_66ae632bedca_5F00_ModuleBuilderLanguageVersionCreator.zip:320:240]
[View:/cfs-file/__key/communityserver-discussions-components-files/296/248a78ce_2D00_ce26_2D00_4a16_2D00_a2ba_2D00_6f0a378aa357_5F00_ModuleBuilderLanguageVersionCreator.zip:320:240]