jshmrtn / vue3-gettext

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

feat: Add option to compile template before extracting #37

Closed win0err closed 1 year ago

win0err commented 1 year ago

This PR fixes the issue when extract script cannot parse strings like in example below.

<template lang="pug">
.not-found-page
    .not-found-page__text.content
        h1.content__title {{ $gettext('Page not found') }}
        p.content__subtitle {{ $gettext('Sorry, we couldn\'t find the page you\'re looking for.') }}
        img.content__image(
            :src="image.src",
            :alt="$gettext('Just an example of using gettext in pug template')",
        )
    // ...
</template>

This PR fixes this behavior, but numbers of parsed lines in *.po files will always be 1 for compiled templates. Fixing this is out of scope of the feature. That's why I've added an option compileTemplate to enable my fix.

If you have any suggestions or questions — feel free to ask!

P.S. Thank you for the project!

lzurbriggen commented 1 year ago

@win0err Thanks for the PR. I can't release this immediately unfortunately, I need to fix some stuff in my setup first.

PS: Sorry for rebasing your branch, I was a bit confused when experimenting with Gitlab Actions.

win0err commented 1 year ago

@lzurbriggen, no problems! We use a patched version in our project. Feel free to ping me if you need any assistance, I really like this project :-)