jshmrtn/vue3-gettext

Messages in native <template> tags do not get extracted

tcitworld opened this issue · 4 comments

Versions:

  • vue 3.2.31
  • vue3-gettext 2.2.0-alpha.1
  • gettext-extractor 3.5.4

The messages are not extracted in this configuration

<template>
  <router-link>
    <template v-if="mode === 'list'">{{ $gettext('Map') }}</template>
    <template v-else>{{ $gettext('List') }}</template>
  </router-link>
</template>

But this one works

<template>
  <router-link>
    <span v-if="mode === 'list'">{{ $gettext('Map') }}</span>
    <span v-else>{{ $gettext('List') }}</span>
  </router-link>
</template>

Possibly a limitation with Gettext Extractor itself, didn't check yet.

Yes, this seems to be a gettext-extractor issue that has to be fixed upstream. It's a bit weird that <template>{{ $gettext("TRANSLATETHIS2") }}</template> works but <template><template>{{ $gettext("TRANSLATETHIS2") }}</template></template> does not.

Same with composition API and setup, can't get anything to extract within it.

<script setup>
import { $gettext } from 'wherever'
$gettext('hello')
</script>

@fjeddy I finally found the time to look at that issue and managed to fix it. Release in 2.2.1.

This problem is separate from the <template> issue, I may not be able to fix that one in the near future.

@tcitworld I managed to fix this, released in 2.2.2.