lingui extract format --minimal not converting old messages.json files and produces faulty statistics.
See original GitHub issueThe 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:
- Created 6 years ago
- Reactions:1
- Comments:10 (6 by maintainers)
Top GitHub Comments
I agree,
lingui
format is overkill for most usecases. The change is ready innext-2
branch and will be released soon in 2.x release.Fixed in
@lingui/cli@2.0.0
. See release docs