This script uses the great message extraction library gettext-extractor by lukasgeiter.
The script assumes that the location of the source files is ./src. It parses both .js and .vue files. It writes the PO template file in ./i18n/messages.pot.
Some things to note:
- It assumes that interpolations in the templates use the delimieters
{{}}(it is the most commmon case). - It assumes that both the template and the script sections of the
.vuesingle file components are defined inline, and not referenced by asrcattribue (it is the most common case). - Expressions to extract are hardcoded. Currently they are
['$t', '[this].$t', 'i18n.t'].
Edits:
- Use parse5-sax-parser
- Fix runtime error preventing the script from running (might not be efficient with large files)
- Add mkdirp to dynamically create the folder if it doesn't exist
- Parse js, jsx, ts and tsx files