jshmrtn/vue3-gettext

Problems with extracting text from <script setup>

fskarmeta opened this issue · 3 comments

Hello !
First of all thanks for creating this tool :D

I'm currently having difficulties to extract translated text inside the script setup.

<script setup>
import { computed } from "vue";
import gettext from "../utils/gettext";
const { $gettext } = gettext;
const someText1 = $gettext(
  "hi this is just some text in a variable translated"
);
const someText2 = computed(() =>
  $gettext("This is a computed text translated")
);
</script>

<template>
  <div>
    <h1>
      {{ $gettext("Hello from Dashboard") }}
    </h1>
    <h2>{{ someText1 }}</h2>
    <h2>{{ someText2 }}</h2>
    <div>
    </div>
  </div>
</template>

The $gettext function works just fine in the template, but it's not extracting the strings from the script template.
I was wondering if i'm missing something or this feature is not yet implemented.

my gettext.js is just the createGettext instance that gets also imported in main.js and used in the app.

Thanks beforehand for any help !

@fskarmeta I only fixed the extract in script setup recently, can you confirm that you use a version >=2.2.1? Also, does the extraction work for regular <script> sections (in the same project)?

@lzurbriggen
i've "vue3-gettext": "^2.2.0-alpha.1" in package.json and its installing that version also after npm install.

    "vue3-gettext": {
      "version": "2.2.0-alpha.1",
      "resolved": "https://registry.npmjs.org/vue3-gettext/-/vue3-gettext-2.2.0-alpha.1.tgz",
      "integrity": "sha512-VQe9YRWqKGkqpb9xGk1/hMrUztLoHzvjof1++OSvaeNdJA3MWo1AHtmQtmoYZaFKUEBmwhrbcb+rBlu5rGOQAA==",
      "requires": {
        "chalk": "^4.1.2",
        "command-line-args": "^5.2.1",
        "cosmiconfig": "^7.0.1",
        "gettext-extractor": "^3.5.3",
        "glob": "^7.2.0",
        "pofile": "^1.1.3",
        "tslib": "^2.3.1"
      }
    },

you mean <script> section with setup() and defineComponent or options API?

Changed manually to "vue3-gettext": "^2.2.1" and its working. Thanks a lot !! @lzurbriggen