js-lingui: Message context (msgctxt) not working

Describe the bug When providing context to a message, the context is treated like an ID in the generated en.po file.

To Reproduce With the version 3.13.1 with create-react-app, and not specifying orderBy in lingui.config.js:

import { Trans } from "@lingui/react"

export default function App() {
  return <div>
    <Trans context='ctxtA'>My string</Trans>
    <Trans context='ctxtB'>My string</Trans>
    <Trans>My string</Trans>
  </div>
}

Expected behavior 3 messages should be created in the generated en.po file, like this:

#: src/App.tsx:11
msgid "My string"
msgstr "My string"

#: src/App.tsx:12
msgctxt "ctxtA"
msgid "My string"
msgstr "My string"

#: src/App.tsx:13
msgctxt "ctxtB"
msgid "My string"
msgstr "My string"

Actual behavior This is created in the en.po file.

#: src/App.tsx:11
msgid "My string"
msgstr "My string"

msgid "ctxtA"
msgstr "ctxtA"

msgid "ctxtB"
msgstr "ctxtB"

Additional context If using orderBy: 'origin' in lingui.config.js, an exception is thrown in getFirstOrigin() when running extract.

  • jsLingui version 3.13.1
  • Using create-react-app

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (13 by maintainers)

Most upvoted comments

@semoal or anyone managing this repository, please prevent stale bot to close this issue, the related PR took days of effort, and we really like to see it integrated into linguijs instead of going with a fork.

We (at my company) have a working fix @tfhult , PR is incoming for the next days.

@semoal or @tricoder42 or anyone, are you still maintaining this project?