useInlineSnippet()
WARNING
Single File Component (SFC) support for Administration extensions is experimental. It is available since Shopware 6.7.16.0. The APIs described on this page can still change without a deprecation. Try it out and tell us what you find, but do not ship an extension built on it to customers or to the Shopware Store until the API is declared stable (planned for 6.9).
ts
import { useInlineSnippet } from 'shopware:composables';
function useInlineSnippet(): {
getInlineSnippet: (value: { [locale: string]: string }) => string | { [locale: string]: string };
};Resolves an inline snippet: an object keyed by locale, the way a configuration field stores a label a merchant translated themselves.
ts
const { getInlineSnippet } = useInlineSnippet();
// { 'de-DE': 'Marge', 'en-GB': 'Margin' } -> 'Margin' in an English Administration
const label = computed(() => getInlineSnippet(props.element.config.label.value));It tries the current locale, then the fallback locale, then the first entry that is not empty. When the value is not an object at all it comes back unchanged, so a plain string passes through.
Replaces the sw-inline-snippet mixin.