Skip to content

Commit

Permalink
Replacements no context extraction hotfix & tests (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
star4beam authored Sep 15, 2022
1 parent 2d60cd6 commit 6991660
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/scripts/babel-gettext-extractor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default function plugin() {
context[translate.msgid] = translate

if (replacements) {
const contextName = translate.msgctxt
const contextName = translate.msgctxt || ""
const contextReplacements = replacements[contextName]
if (
contextReplacements &&
Expand Down
16 changes: 14 additions & 2 deletions test/specs/scripts/extract.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,20 @@ describe('extract', () => {

const messages = readFileSync(`${replacementsDir}/messages.pot`).toString("utf-8")

expect(messages).toContain('msgid "Needs replacement"')
expect(messages).toContain(`msgid "A replacement for 'Needs replacement'`)

expect(messages).toContain([
`#: fixtures/replacements/index.js:1`,
`msgid "Needs replacement"`,
`msgstr ""`,
].join('\n'))

expect(messages).toContain([
`#: fixtures/replacements/index.js:1`,
`#. REPLACEMENT for "Needs replacement"`,
`msgid "A replacement for 'Needs replacement'"`,
`msgstr ""`,
].join('\n'))

expect(messages).toContain('#. REPLACEMENT for "Needs replacement"')
expect(messages).toContain('msgid "No replacement is needed"')

Expand Down

0 comments on commit 6991660

Please sign in to comment.