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'].
FYI we needed a similar script for our needs.
It didn't run out of the box (nor did any of the existing forks) so we fixed it here with a few small additions, in case anyone need it: https://gist.github.com/rgoupil/bba97f652701189108cacb9f0ee8d392