question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Message context (msgctxt) not working

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
JSteunoucommented, Dec 5, 2022

@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.

1reaction
JSteunoucommented, Sep 12, 2022

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get msgctxt in .po file with Django and pgetttext()
In your code, the call to pgettext() has the message context in a variable instead of a string literal and such calls are,...
Read more >
Contexts (GNU gettext utilities)
The problem is that many of the strings which have to be translated are very short. ... The msgctxt string is visible in...
Read more >
Add msgctxt-type context to t() [#334283] | Drupal.org
The exact way of doing that has to be discussed, but I suggest the [<context>]<string> convention, as it should not collide with existing ......
Read more >
Language Variables — CS-Cart 4.15.x documentation
Structure of a Language Variable¶ · msgctxt—the message context that serves to identify the same lines of text in different parts of the...
Read more >
Gettext support - Loco - Translation
Working with Gettext in Loco. ... Gettext "msgctxt" strings are equivalent to Loco's own context ... Gettext messages vs Loco assets.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found