jshmrtn / vue3-gettext

Translate Vue 3 applications with gettext.
https://jshmrtn.github.io/vue3-gettext/
MIT License
76 stars 25 forks source link

Issue extracting texts inside labels. #46

Open bspyropoulos opened 1 year ago

bspyropoulos commented 1 year ago

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!

lzurbriggen commented 1 year ago

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.

bspyropoulos commented 1 year ago

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

lzurbriggen commented 3 months ago

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