vue3-gettext icon indicating copy to clipboard operation
vue3-gettext copied to clipboard

Issue extracting texts inside labels.

Open bspyropoulos opened this issue 1 year ago • 3 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!

bspyropoulos avatar Jun 20 '23 07:06 bspyropoulos

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 avatar Jun 20 '23 07:06 lzurbriggen

@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!

bspyropoulos avatar Jun 20 '23 07:06 bspyropoulos

I just implemented a new extraction parser that should be a bit more robust. Nobody has really used it yet, but it seems to parse your failing example correctly.

Make sure to check the breaking changes though: v4.0.0-alpha.4 and v4.0.0-alpha.2

lzurbriggen avatar Aug 08 '24 16:08 lzurbriggen