Hi
What you could do is hook up an event handler to LoadedDefaultContent and check if ContentLink is not null or empty (that is what differs a new language version of a page from a new page). And if so copy all values from master language, something like:
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class PopulateLanguage : IInitializableModule
{
public void Initialize(Framework.Initialization.InitializationEngine context)
{
context.Locate.Advanced.GetInstance<IContentEvents>().LoadedDefaultContent
+= delegate(object sender, ContentEventArgs args)
{
if (!ContentReference.IsNullOrEmpty(args.ContentLink))
{
//For a new language branch will contentLink not be empty
var masterLanguage = context.Locate.ContentLoader()
.Get<IContent>(args.ContentLink,
LanguageSelector.MasterLanguage());
foreach (var prop in masterLanguage.Property
.Where(p => p.IsLanguageSpecific && !p.IsMetaData))
{
args.Content.Property[prop.Name].Value = prop.Value;
}
}
};
}
public void Preload(string[] parameters)
{
}
public void Uninitialize(Framework.Initialization.InitializationEngine context)
{
}
Also take a look at this: http://cjsharp.com/blog/2013/04/19/automatically-populating-page-or-block-type-properties-for-a-language-branch-in-episerver-7/
It's an attribute so you can specify content copying on a per-property basis.
Hi Chris,
I`ve tried your solution but always when I hit translate the e.Content.ContentGuid is empty.
Do you know what can cause the problem?
Thanks,
Daniel
Hi Johan
We tried your approach and the ContentLink is always null/empty.
We noticed that this happens on pages/blocks that have [Required] properties.
As we use [Required] to force the content admins to add the required master content, this is not a usable solution.
When we have a page/block with no [Required] properties it fires the twice, with the first time ContentLink being null, and the second being the actual ContentLink ID of the page/block.
I am guessing this is because of the flow of execution.
As we never see the second request in content with a [Required] field, then I am assuming the system attempts to create a blank content type, cannot do so because of the [Required] fields, and so never actually gets to the second call to LoadedDefaultContent which would populate the content.
Are you aware of this behaviour, or are you aware of a work around?
Thanks
Marin Graney
@Daniel: Are you using EPiServer 7.1? Are you trying to translate a page or a block?
Are there any updates on this subject. It's something I also would like to know.
Personally I find it strange the "page to be translated" is empty. I would expect it to have the original not translated content for reference.
Gert
Are there any updates for this?
We have the exact same issue and required properties are not automatically passed through. We can't do anything about it as the data doesn't appear to be there, on the first pass (ContentLink is empty/null), but IS available, on the second pass, to fill in the rest of the properties.
This is for an Episerver 7.5 site.
Have you tried using the Translation Add-on? It gives you the option to copy content from another language.
Hi
When you localise a page/block to a target culture the translatable fields are emptied, and you have to re-enter them.
Is this the expected behaviour?
As a page/block can contain a lot of translatable fields this forces the end user to enter the translation there and then, block-by-block and page-by-page.
Our client would like to globalise content from english to a target culture without being forced to change it, i.e. copy the english content from en-GB to de-DE say, and then allow translation teams to change the english copy to their native tongue at a later date before publishing the content.
It is also easier for their translation teams if they see the original english master copy in the block/page they are going to translate.
If the abvoe is the expected behviour for translating/globalising pages/blocks in CMS 7.1, can we override it so that when you globalise content from one language branch to another the content is copied from the source culture page/block to the destination culture page/block?
Could we achieve this behaviour using workflows?
Thanks
Martin Graney