the current project I migrated contains lots of locales files related to i18n feature and we have to migrate them, something like this:
// vue2
<template lang="pug">
div(v-show='media(["lg", "sm"])') {{ $t('msg_id_top_game_result_notification_1') }}
</template>
<script>
import messages from '@/locales/pages'
export default {
i18n: {
messages
}
};
</script>
// vue3
<template lang="pug">
div(v-show='media(["lg", "sm"])') {{ t('msg_id_top_game_result_notification_1') }}
</template>
<script setup>
const { t } = useI18n({
useScope: "local",
});
</script>
<i18n lang="json">
{
"en": {
"msg_id_top_game_result_notification_1": "The standings are currently not displayed due to the [Hide Results] setting.",
},
"ja": {
"msg_id_top_game_result_notification_1": "[試合結果を表示しない]に設定しているため、表示されていません。",
}
}
</i18n>
except the migration for javascript part(I have implemented by traverseScriptAST successfully), the challenge here is how to append <script setup> and <i18n lang="json"> to sfcAST and keep its content?
the current project I migrated contains lots of locales files related to i18n feature and we have to migrate them, something like this:
except the migration for javascript part(I have implemented by
traverseScriptAST
successfully), the challenge here is how to append<script setup>
and<i18n lang="json">
tosfcAST
and keep its content?I write a plugin like this to implement it:
anyway, the
<script setup>
could be appended successfully but its content is missing, see the failed unit test screenshot:is there any suggestion here? 😂 feel free to point me something wrong and I will update it.