lukasgeiter / gettext-extractor

A flexible and powerful Gettext message extractor with support for JavaScript, TypeScript, JSX and HTML.
MIT License
98 stars 21 forks source link

Empty line comments are not properly extracted #23

Closed pronebird closed 5 years ago

pronebird commented 5 years ago

Hi,

As per your suggestion in #22 and based on docs, I use multiple single line comments prefixed with the keyword, in my case it's TRANSLATORS:.

However the empty lines are not extracted properly, consider this:

// TRANSLATORS: Product price label
// TRANSLATORS:
// TRANSLATORS: Available placeholder:
// TRANSLATORS: {currency} - the runtime substitution for the price currency
// TRANSLATORS: {amount}   - the runtime substation for the amount

Extracted as:

#. Product price label
#. TRANSLATORS:
#. Available placeholder:
#. {currency} - the runtime substitution for the price currency
#. the runtime substation for the amount

I would expect that the second line in the generated POT has to be an empty string, i.e: #. only.

The regex I use: /^TRANSLATORS:\s*(.*)$/. Running it manually via match works fine:

> "TRANSLATORS:".match(/^TRANSLATORS:\s*(.*)$/)
[ 'TRANSLATORS:',
  '', // <-- empty string - ALL GOOD
  index: 0,
  input: 'TRANSLATORS:',
  groups: undefined ]