useTranslateWithFallback()
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 { useTranslateWithFallback } from 'shopware:composables';
function useTranslateWithFallback(): {
tWithFallback: (key: string) => string;
};Translates a snippet key against the active locale and, when there is no entry there, against the fallback locale.
A plugin cannot import vue-i18n, so <script setup> has no t() of its own. This is how a script translates a key.
ts
const { tWithFallback } = useTranslateWithFallback();
const title = computed(() => tWithFallback('swag-margin.detail.title'));A key that exists in neither locale comes back as the key itself.
Replaces the translate-with-fallback mixin.