jshmrtn/vue3-gettext

Issue extracting texts inside labels.

Opened this issue · 2 comments

Hello! Apparently there is an issue extracting texts inside labels when they have the for attribute. i.e
This doesn't work:
<label for="company-website" class="tw-block tw-text-sm tw-font-medium tw-leading-6 tw-text-gray-900">{{ $gettext("bla bla") }}</label>
but this one does:
<label class="tw-block tw-text-sm tw-font-medium tw-leading-6 tw-text-gray-900">{{ $gettext("bla bla") }}</label>

UPDATE
Seems to happening only when label with for attribute is inside a v-for block.

Is there a known workaround? Thanks in advance!

hi @bspyropoulos, i have not seen this one yet and don't have a lot of time lately, so I don't know how soon there'll be a proper fix.

Is there a known workaround?

you can always translate in the <script> block.

const { $gettext } = useGettext();

const labelText = $gettext("bla bla");

wrapping your label or doing your v-for in a <template> may also work, but i don't know what the root of the issue is so i'm not sure.

@lzurbriggen just noticed this bug. I haven't found a workaround. Surely i will try to translate those words in <script> block. I also tried using :for instead of the native attribute and adding a string but it didn't work.
Thanks for the quick response though!