gettext-vue

Extract translatable strings from Vue files
13,854 16
Install
npm install gettext-vue
Latest Version:0.4.1
License:MIT
Last Updated:Jun 22, 2022
Links: GitHub  ·  npm
Maintainer: gui

gettext-vue

Extract translatable strings from Vue files. By default, looks for the keywords $t, $gettext, and $ngettext.

Installation

npm install -g gettext-vue

Usage

xgettext-vue [OPTION] [INPUTFILE]...
Options
Input file location:
  -f, --files-from  get list of input files from FILE
  -D, --directory   add DIRECTORY to list for input files search[default: ["."]]

Output file location:
  -o, --output  write output to specified file          [default: "messages.po"]

Input file interpretation:
  --from-code  encoding of input files                        [default: "ascii"]

Operation mode:
  -j, --join-existing  join messages with existing file         [default: false]

Output details:
  --force-po     write PO file even if empty                    [default: false]
  --no-location  do not write '#: filename:line' lines          [default: false]

Informative output:
  -h, --help     display this help and exit                            [boolean]
  -V, --version  output version information and exit                   [boolean]

API

new Parser(keywordspec)

Creates a new parser.

The keywordspec parameter is optional, with the default being:

{
  '$t': [0],
  '$gettext': [0],
  '$ngettext': [0, 1]
}

Each keyword (key) requires array of argument number(s) (value). When multiple argument numbers are specified, expressions using this keyword are treaded as single-plural.

.parse(template)

Parses the template string for Swig expressions using the keywordspec.

It returns an object with this structure:

{
  msgid1: {
    line: [1, 3]
  },
  msgid2: {
    line: [2],
    plural: 'msgid_plural'
  }
}

Credits

Largely based on gettext-ejs and xgettext-template

Related Packages

vue3-gettext

Translate Vue 3 applications with gettext

865,515 86
vue-lang

Vue.js i18n language integration

12,913 11
@rareformlabs/vue3-gettext

Translate Vue 3 applications with gettext (maintained fork)

7,088 1
@generaltranslation/vue-extractor

Vue source code extraction for General Translation

410,565 1,070
@byjohann/vue-i18n

Lightweight internationalization plugin for Vue

8,721 7

Version History

Version Released License
0.4.1 MIT
0.4.0 MIT
0.3.1 MIT
0.3.0 MIT
0.2.0 MIT