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.

messages.json is looking different than in documentation

See original GitHub issue

Following https://lingui.gitbooks.io/js/tutorials/react.html got me to:

Now we're ready to extract messages:
$ lingui extract

And then it shows nicely formatted language file:

{
  "Message Inbox": "",
  "See all <0>unread messages</0> or <1>mark them</1> as read.": "",
  "{messagesCount, plural, one {There's {messagesCount} message in your inbox.} other {There're {messagesCount} messages in your inbox.}}": "",
  "Last login on {lastLogin, date}": ""
}

However mine looks very different, containing origin values (it does compile though):

{
  "StringOne": {
    "translation": "",
    "origin": [
      [
        "src\\components\\common\\Header.js",
        26
      ]
    ]
  },
  "StringTwo": {
    "translation": "",
    "origin": [
      [
        "src\\components\\common\\Header.js",
        53
      ]
    ]
  }
}

What am I doing wrong? I was just following the tutorial.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tricoder42commented, Aug 14, 2017

Use i18n._("Raw string") for this, that’s the “raw” method. In React, you have to use <Trans id="Raw string" />. I’ll add this into docs.

However, this way the message won’t be extracted. I need to add sth like i18n.noop which will just mark static messages for extraction, but won’t perform any translation. So your example would be:

export default [
[route: '/', title:  i18n.noop('Homepage')],
[route: '/about', title: i18n.noop('About')],
...etc
]

And later you would use:

const title = i18n._(route.title)

// or
<Trans id={route.title} />

Good points anyway. Thank you and sorry for any inconveniences.

0reactions
tricoder42commented, Aug 14, 2017

Create a new issue for this feature: #60

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with JSON - Learn web development | MDN
In this article, we've given you a simple guide to using JSON in your programs, including how to create and parse JSON, and...
Read more >
Syntax for documenting JSON structure - Stack Overflow
Other than this, my personal opinion is that since JSON is predominantly used for transferring objects, documenting equivalent objects in ...
Read more >
Parsing message formats - Amazon Simple Notification Service
Describes the message and JSON formats that Amazon SNS supports.
Read more >
Working with Messages - JSON - 9.8 Technical Documentation
In this learning activity, the first name and last name nodes are mapped to names different that the default value name. Learning activity....
Read more >
An Introduction to JSON | DigitalOcean
JSON — short for JavaScript Object Notation — is a format for sharing data. As its name suggests, JSON is derived from the...
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