Determine master language in EditorDescriptor

Ted
Ted
Vote:
 

Scenario:

  1. Content is created in English which becomes the master language
  2. User switches to a different language
  3. CMS prompts user to translate the content to the current language
  4. User clicks "Translate" which creates content in the current language

In step 4, when user selects "Translate", the content passed to editor descriptors is essentially an entirely new content instance. In other words, it has status "NotCreated" and does not contain any information about the master language version that is effectively being translated.

So, is there any way, in an editor descriptor, to figure out what the current master language is (i.e. which existing content is being translated)?

#314085
Edited, Dec 12, 2023 15:00
Ted
Vote:
 

guess I could go for a hack looking at the current request context, but that feels brittle... 🙈

#314126
Dec 13, 2023 8:41
Ted - Dec 14, 2023 10:15
Neither me nor Eric below found a better way, so I guess this is the "solution" for now. :)
Vote:
 

We do some magic in EditorDescriptors like this

protected override void SetEditorConfiguration(ExtendedMetadata metadata)
{
    _contentLoader.TryGet(ContentReference.StartPage, out StartPageBase startPage);
    // startPage.IsMasterLanguageBranch is available here
    EditorConfiguration["data"] = startPage?.Whatever?.ToString() ?? string. Empty;
    base.SetEditorConfiguration(metadata);
}

You can probably load the correct content reference from the property in the screenshot. Can't really see any other way. 

#314127
Dec 13, 2023 10:32
Ted - Dec 13, 2023 10:44
Thanks for the tip, but the master language of the content being translated isn't necessarily the same master language as the start page? Or am I missing something?
Eric Herlitz - Dec 13, 2023 20:59
I figured you could resolve the current contentReference from the metadata property
Ted - Dec 13, 2023 21:31
Ah, ok, misunderstood the purpose of the code sample... Yeah, getting the content reference from the header worked just fine, although I'm not sure Optimizely would consider it a breaking change if they changed/removed it. :)
Eric Herlitz - Dec 14, 2023 22:02
Oh man they would never! :)
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.