gettext-extractor-vue is a specialized extension for the `gettext-extractor` library, designed to facilitate the extraction of gettext messages from Vue Single File Components (SFCs). It works by decorating `gettext-extractor`'s `JSExtractor` to preprocess `.vue` files, transforming their template and script sections into standard JavaScript that the core `gettext-extractor` can then parse. The current stable version is 5.2.0. This package differentiates itself by offering compatibility with both Vue 2 applications (requiring `vue-template-compiler` as a user-provided dependency) and Vue 3 applications (requiring `@vue/compiler-sfc`). Additionally, it provides utility functions, such as `decorateExtractorWithHelpers`, to add message transformation capabilities to the core `GettextExtractor` instance. While its release cadence isn't strictly defined, it generally aligns with major versions of `gettext-extractor` and Vue itself to ensure ongoing compatibility.
npm install gettext-extractor-vueVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `gettext-extractor` with `gettext-extractor-vue` to parse both JavaScript and Vue Single File Components (SFCs), saving extracted messages to a `.pot` file. It shows how to integrate `decorateJSParserWithVueSupport` and highlights the conditional requirement for `vue-template-compiler` (for Vue 2) or `@vue/compiler-sfc` (for Vue 3).
Install `gettext-extractor`: `npm install gettext-extractor` or `yarn add gettext-extractor`.
For Vue 2: `npm install vue-template-compiler`. For Vue 3: `npm install @vue/compiler-sfc`.
For ESM: `import { func } from 'gettext-extractor-vue';`. For CJS: `const { func } = require('gettext-extractor-vue');`.Install the appropriate Vue compiler: `npm install vue-template-compiler` for Vue 2, or `npm install @vue/compiler-sfc` for Vue 3.
Ensure `gettext-extractor` is correctly installed and its version satisfies the peer dependency requirement: `npm install gettext-extractor`.