© 2026 Hedgehog Software, LLC
result
{ test: { title: 'test' } }
Record<string, unknown>
function test<T, K extends { nested: Record<string, T> }>(data: K) { return data.nested; } const testdata = { nested: { test: { title: 'Test', } } } const result = test(testdata);
export default function useTranslation() { const { locale } = useI18n(); type Translatable<K, T> = K & { translations: Record<string, T> }; function translate<T, K>(data: Translatable<T, K>) { const { translations, ...rest } = data; const definedLocales = computed(() => Object.keys(translations)); const translation = computed(() => definedLocales.value.includes(locale.value) ? translations[locale.value] : translations[definedLocales.value[0]]); const result = computed(() => ({ ...rest, ...translation.value })); return toReactive(result); } return { translate, }; }
function translate<T>(data: { translations: Record<string, T> })
object