Difference UMB_DOCUMENT_WORKSPACE_CONTEXT and UMB_VARIANT_WORKSPACE_CONTEXT + how to determine variant language?

Hi all,

I’m building a package and I want to support multiple languages. So I need to know what the current language is of the content I’m editing/showing in my component. And in researching this, I came across two questions:

  • How do I get the variant language that I’m editing in the context of my component? This is especially important in split view!
  • Whats the difference between UMB_DOCUMENT_WORKSPACE_CONTEXT and UMB_VARIANT_WORKSPACE_CONTEXT? They seems completely the same.

Getting the current app language is not difficult:

this.consumeContext(UMB_APP_LANGUAGE_CONTEXT, (instance) => {
	console.log("App culture: " + instance.getAppCulture());
});

However, this is not enough in two scenario’s:

  • When the node is invariant, I don’t want to have a culture, but the app culture will always have a value.
  • In split view, there is more than one language.

So you can check the active variants like this:

this.consumeContext(UMB_DOCUMENT_WORKSPACE_CONTEXT, async (instance) => {
	console.log("Active variants:",instance?.splitView.activeVariantsInfo);
}

This will nicely get an invariant culture when there is no vary by culture, or a culture if there is one:
image
image

Nice! However, now comes the split view scenario. Consider this:

This will give an array of active variants from the activeVariantsInfo:
image

That makes sense, but how on earth do I know in the context of my component what variant I’m showing/editing??

I thought that the UMB_VARIANT_WORKSPACE_CONTEXT would provide more information about the active variant compared to UMB_DOCUMENT_WORKSPACE_CONTEXT. However, they seem absolutely identical in terms of data, functions and properties. What’s the difference?

Hi @LuukPeters
This looks like this will be the thing to use from 16.0 onwards

Yeah I guess so. In 15 I didn’t see ANY difference between the two. It doesn’t matter that much, it’s more of an edge case, but still. For now, I’ll consider it closed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.