lukasgeiter / gettext-extractor

A flexible and powerful Gettext message extractor with support for JavaScript, TypeScript, JSX and HTML.
MIT License
98 stars 21 forks source link

Unable to parse dynamic attributes from *.vue files #40

Closed aadjemonkeyrock closed 4 years ago

aadjemonkeyrock commented 4 years ago

I'm parsing *.vue single file components and it works pretty well, except for a small issue. I'm not able to parse the translations from dynamic properties. See example below:

<template>
    <div style="padding: 24px;">
        <h1 :title="c_title">Translations</h1>
        <p>TRMSave -> {{ $t("Save") }}</p>
        <p>Message from script: {{ message }}</p>
        <button :title="$t('Quotation')" class="btn btn--is-primary">{{ $t('Invoice') }}</button>
    </div>
</template>

<script>

export default {
    data() {
        return {
            message: ""
        };
    },
    computed: {
        c_title() {
            return this.$t('Close'); 
        }   
    },
    created() {
        this.message = this.$t('All messages')
    }
};
</script>

In this example everything works, except for the :title="$t('Quatation')" It's just not recognized.

Is there any work around the issue?

lukasgeiter commented 4 years ago

That's currently not possible as it requires framework specific parsing. I'm planning to enable such use cases in a future release. Until then, the only workaround I'm aware of is moving the call into the JavaScript code like you did with c_title.

aadjemonkeyrock commented 4 years ago

Thx, I appreciate your good work