jshmrtn / vue3-gettext

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

startLine can be undefined #13

Closed tcitworld closed 2 years ago

tcitworld commented 2 years ago

When running vue-gettext-extract on the latest alpha version:

[...]/my_project/node_modules/vue3-gettext/dist/bin/gettext_extract.js:79
                lineNumberStart: (_a = element.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs[attr.name].startLine,
                                                                                                                            ^

TypeError: Cannot read properties of undefined (reading 'startLine')
    at [...]/my_project/node_modules/vue3-gettext/dist/bin/gettext_extract.js:79:125
    at Array.forEach (<anonymous>)
    at [...]/my_project/node_modules/vue3-gettext/dist/bin/gettext_extract.js:76:23
    at HtmlParser.parseNode ([...]/my_project/node_modules/gettext-extractor/dist/html/parser.js:19:13)
    at HtmlParser.parseNode ([...]/my_project/node_modules/gettext-extractor/dist/html/parser.js:24:49)
lzurbriggen commented 2 years ago

@tcitworld I'll merge you fix soon. Out of curiosity, do you know under what circumstances the problem occurred (file, attribute, value)?

tcitworld commented 2 years ago

The last file to be listed before the error has nothing special about it, so I'm not sure the issue comes from here:

<template>
  <div class="h-96 font-light py-12 px-4 md:px-8 mb-8">
    <div class="max-w-3xl w-full mx-auto z-10 h-full">
      <div class="flex flex-col h-full">
        <div
          class="
            flex
            bg-white
            border border-white
            shadow-lg
            rounded-xl
            p-4
            m-4
            h-full
            place-content-center
            align-middle
            place-items-center
          "
        >
          <svg
            class="animate-spin -ml-1 mr-3 h-5 w-5 text-black"
            xmlns="http://www.w3.org/2000/svg"
            fill="none"
            viewBox="0 0 24 24"
          >
            <circle
              class="opacity-25"
              cx="12"
              cy="12"
              r="10"
              stroke="currentColor"
              stroke-width="4"
            ></circle>
            <path
              class="opacity-75"
              fill="currentColor"
              d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
            ></path>
          </svg>
          <translate>Loading...</translate>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "LoadingComponent",
};
</script>
lzurbriggen commented 2 years ago

@tcitworld I see 🤷‍♂️ . I just released 2.0.0-alpha.3 with your fix. Please reopen the issue if the problem persists.