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.

lingui extract format --minimal not converting old messages.json files and produces faulty statistics.

See original GitHub issue

The lingui extract --format works when converting existing messages.json files from minimal to lingui, but not vice versa. The output format is wrong, and the statistics are faulty (claims that no translations are missing).

Setup

lingui-cli@1.4.2, lingui-react@1.4.1, babel-plugin-lingui-extract-messages@1.1.10, lingui-conf@0.12.0, Windows 10

How to reproduce?

Using following test component:

import React from 'react'
import { Trans, Plural } from 'lingui-react'

const Testi18n = () => {
  return (
    <div>
      <Trans>This is a test</Trans>
      <Plural
        value={messagesCount}
        one="There's # message in your inbox"
        other="There're # messages in your inbox"
      />
    </div>
  )
}

export default Testi18n

(1) First, add locales -> will have messages.json files with only β€œ{}” as content.

(2) lingui extract --format minimal produces messages.json in the following format:

{
  "This is a test": "",
  "{messagesCount, plural, one {There's # message in your inbox} other {There're # messages in your inbox}}": ""
}

and following statistics

Catalog statistics:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Language β”‚ Total count β”‚ Missing β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ en_US    β”‚      2      β”‚    2    β”‚
β”‚ fi_FI    β”‚      2      β”‚    2    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

(3) lingui extract --format lingui produces messages.json in following format:

{
  "This is a test": {
    "origin": [
      [
        "reactjs\\scenes\\Testi18n.jsx",
        7
      ]
    ]
  },
  "{messagesCount, plural, one {There's # message in your inbox} other {There're # messages in your inbox}}": {
    "origin": [
      [
        "reactjs\\scenes\\Testi18n.jsx",
        8
      ]
    ]
  }
}

and following statistics

Catalog statistics:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Language β”‚ Total count β”‚ Missing β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ en_US    β”‚      2      β”‚    2    β”‚
β”‚ fi_FI    β”‚      2      β”‚    2    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

(4) Running lingui extract --format minimal produces messages.json files in this format:

{
  "This is a test": {
    "origin": [
      [
        "reactjs\\scenes\\Testi18n.jsx",
        7
      ]
    ]
  },
  "{messagesCount, plural, one {There's # message in your inbox} other {There're # messages in your inbox}}": {
    "origin": [
      [
        "reactjs\\scenes\\Testi18n.jsx",
        8
      ]
    ]
  }
}

and following statistics

Catalog statistics:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Language β”‚ Total count β”‚ Missing β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ en_US    β”‚      2      β”‚    0    β”‚
β”‚ fi_FI    β”‚      2      β”‚    0    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
tricoder42commented, Jan 3, 2018

I agree, lingui format is overkill for most usecases. The change is ready in next-2 branch and will be released soon in 2.x release.

0reactions
tricoder42commented, Jan 23, 2018

Fixed in @lingui/cli@2.0.0. See release docs

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lingui Configuration β€” LinguiJS documentation
Defines location of message catalogs and what files are included when extract is scanning for messages. path shouldn't end with slash and it...
Read more >
Lingui Configuration β€” LinguiJS documentation
Defines location of message catalogs and what files are included when extract is scanning for messages. path shouldn't end with slash and it...
Read more >
How do I parse this JSON skype history thing?
Hello, So finally Skype make a tool to export chat history from Skype 8.x... https://secure.skype.com/my/data-export And what does it make?
Read more >
xDY - River Thames Conditions - Environment Agency - GOV.UK
#diode Mash imdb tv, Alamah lightings, Format spt pph pasal 22, Hasselblad h3d 39 used, Trees ppt template, Cyma reversa definition, Leica 0-seriesΒ ......
Read more >
Untitled
Thomas fraas helmbrechts, El periodo rosista wikipedia, Footjoy icon 52347, Wifi not working on iphone 4s sprint, Como fazer molde de blusas, Roycopper?...
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