-
- Notifications
You must be signed in to change notification settings - Fork 378
Open
Labels
Status: ProposalRequest for commentsRequest for commentsType: FeatureIncludes new featuresIncludes new features
Description
Vue 3 has this yet experimental syntax Script Setup 'SFC Composition API Syntax Sugar'.
I'm wondering how to best expose the translation method t in components written with this syntax.
Currently this syntax is working for me:
<script setup lang="ts"> import { useI18n } from 'vue-i18n'; const { t } = useI18n(); export const name = 'ViewName'; // Note: vue-meta package does not support Vue 3 as of yet, but am verifying functionality // by being able to use this object in template syntax. export const metaInfo = { title: t('PAGE_TITLE'), meta: [ { name: 'description', content: t('PAGE_DESCRIPTION') }, ], }; </script> <template> <h1>{{ metaInfo.title }}</h1> </template>However, I would like to be able to write it like this:
<script setup lang="ts"> export const name = 'ViewName'; export const metaInfo = { title: $t('PAGE_TITLE'), meta: [ { name: 'description', content: $t('PAGE_DESCRIPTION') }, ], }; </script>Would it be possible for this library to automatically expose $t method in script setup scope? Or by object-destructuring from setup context <script setup="_, { $t }" lang="ts">?
lguilins and natemate90
Metadata
Metadata
Assignees
Labels
Status: ProposalRequest for commentsRequest for commentsType: FeatureIncludes new featuresIncludes new features