Message context (msgctxt) not working
See original GitHub issueDescribe 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:
- Created 2 years ago
- Comments:17 (12 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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?