Skip to content

Commit 6c4193a

Browse files
committed
Merge branch 'main' into next
2 parents 473b70f + 8dcb749 commit 6c4193a

File tree

31 files changed

+714
-24
lines changed

31 files changed

+714
-24
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)
7+
8+
### Bug Fixes
9+
10+
- **extract:** when files are used, don't overwrite obsolete ([#1964](https://github.com/lingui/js-lingui/issues/1964)) ([e726b16](https://github.com/lingui/js-lingui/commit/e726b16a2a9299913d386489d92e0daa9c42e40d))
11+
12+
### Features
13+
14+
- **format-po-gettext:** respect Plural-Forms header ([#2070](https://github.com/lingui/js-lingui/issues/2070)) ([5d0516e](https://github.com/lingui/js-lingui/commit/5d0516e5ee8de5bd4369e8760b4a5c77259853db))
15+
616
# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)
717

818
### Features

packages/babel-plugin-extract-messages/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)
7+
8+
**Note:** Version bump only for package @lingui/babel-plugin-extract-messages
9+
610
# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)
711

812
**Note:** Version bump only for package @lingui/babel-plugin-extract-messages

packages/cli/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)
7+
8+
### Bug Fixes
9+
10+
- **extract:** when files are used, don't overwrite obsolete ([#1964](https://github.com/lingui/js-lingui/issues/1964)) ([e726b16](https://github.com/lingui/js-lingui/commit/e726b16a2a9299913d386489d92e0daa9c42e40d))
11+
612
# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)
713

814
**Note:** Version bump only for package @lingui/cli

packages/cli/src/api/catalog/mergeCatalog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function mergeCatalog(
4949
const obsoleteMessages = obsoleteKeys.map((key) => ({
5050
[key]: {
5151
...prevCatalog[key],
52-
obsolete: !options.files,
52+
...(!options.files && { obsolete: true }),
5353
},
5454
}))
5555

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
msgid ""
2+
msgstr ""
3+
"POT-Creation-Date: 2023-03-15 10:00+0000\n"
4+
"MIME-Version: 1.0\n"
5+
"Content-Type: text/plain; charset=utf-8\n"
6+
"Content-Transfer-Encoding: 8bit\n"
7+
"X-Generator: @lingui/cli\n"
8+
"Language: en\n"
9+
"Project-Id-Version: \n"
10+
"Report-Msgid-Bugs-To: \n"
11+
"PO-Revision-Date: \n"
12+
"Last-Translator: \n"
13+
"Language-Team: \n"
14+
"Plural-Forms: \n"
15+
16+
#. js-lingui-explicit-id
17+
#: fixtures/file-a.ts:11
18+
#~ msgid "custom.id"
19+
#~ msgstr "This message has custom id"
20+
21+
#. js-lingui-explicit-id
22+
#: fixtures/file-a.ts:22
23+
#: fixtures/file-a.ts:23
24+
msgid "addToCart"
25+
msgstr "Add To Cart with change ignored"
26+
27+
#. this is a comment
28+
#: fixtures/file-b.tsx:6
29+
msgid "Hello this is JSX Translation"
30+
msgstr "Hello this is JSX Translation"
31+
32+
#: fixtures/file-b.tsx:11
33+
msgctxt "my context"
34+
msgid "Hello this is JSX Translation"
35+
msgstr "Hello this is JSX Translation"
36+
37+
#: fixtures/file-a.ts:4
38+
msgid "Hello world"
39+
msgstr "Hello world"
40+
41+
#: fixtures/file-a.ts:6
42+
msgctxt "custom context"
43+
msgid "Hello world"
44+
msgstr "Hello world"
45+
46+
#: fixtures/file-a.ts:16
47+
msgid "Message in descriptor"
48+
msgstr "Message in descriptor"
49+
50+
#. js-lingui-explicit-id
51+
#: fixtures/file-b.tsx:15
52+
msgid "jsx.custom.id"
53+
msgstr "This JSX element has custom id"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
msgid ""
2+
msgstr ""
3+
"POT-Creation-Date: 2023-03-15 10:00+0000\n"
4+
"MIME-Version: 1.0\n"
5+
"Content-Type: text/plain; charset=utf-8\n"
6+
"Content-Transfer-Encoding: 8bit\n"
7+
"X-Generator: @lingui/cli\n"
8+
"Language: en\n"
9+
"Project-Id-Version: \n"
10+
"Report-Msgid-Bugs-To: \n"
11+
"PO-Revision-Date: \n"
12+
"Last-Translator: \n"
13+
"Language-Team: \n"
14+
"Plural-Forms: \n"
15+
16+
#. js-lingui-explicit-id
17+
#: fixtures/file-a.ts:11
18+
#~ msgid "custom.id"
19+
#~ msgstr "This message has custom id"
20+
21+
#. js-lingui-explicit-id
22+
#: fixtures/file-a.ts:22
23+
#: fixtures/file-a.ts:23
24+
msgid "addToCart"
25+
msgstr "Add To Cart with change ignored"
26+
27+
#. this is a comment
28+
#: fixtures/file-b.tsx:6
29+
msgid "Hello this is JSX Translation"
30+
msgstr "Hello this is JSX Translation"
31+
32+
#: fixtures/file-b.tsx:11
33+
msgctxt "my context"
34+
msgid "Hello this is JSX Translation"
35+
msgstr "Hello this is JSX Translation"
36+
37+
#: fixtures/file-a.ts:4
38+
msgid "Hello world"
39+
msgstr "Hello world"
40+
41+
#: fixtures/file-a.ts:6
42+
msgctxt "custom context"
43+
msgid "Hello world"
44+
msgstr "Hello world"
45+
46+
#: fixtures/file-a.ts:16
47+
msgid "Message in descriptor"
48+
msgstr "Message in descriptor"
49+
50+
#. js-lingui-explicit-id
51+
#: fixtures/file-b.tsx:15
52+
msgid "jsx.custom.id"
53+
msgstr "This JSX element has custom id"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { i18n } from "@lingui/core"
2+
import { defineMessage, t } from "@lingui/macro"
3+
4+
const msg = t`Hello world`
5+
6+
const msg2 = t({
7+
message: "Hello world",
8+
context: "custom context",
9+
})
10+
11+
const msg3 = null /* original translation commented to mark message obsolete *//*t({
12+
message: "This message has custom id",
13+
id: "custom.id",
14+
})*/
15+
16+
const msgDescriptor = defineMessage({
17+
message: "Message in descriptor",
18+
})
19+
20+
i18n._(msgDescriptor)
21+
22+
i18n._("addToCart")
23+
i18n._({id: "addToCart", message: "Add To Cart with change ignored"})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Trans } from "@lingui/macro"
2+
import React from "react"
3+
4+
export function MyComponent() {
5+
return (
6+
<Trans comment={"this is a comment"}>Hello this is JSX Translation</Trans>
7+
)
8+
}
9+
10+
export function MyComponent2() {
11+
return <Trans context="my context">Hello this is JSX Translation</Trans>
12+
}
13+
14+
export function MyComponent3() {
15+
return <Trans id={"jsx.custom.id"}>This JSX element has custom id</Trans>
16+
}

packages/cli/test/index.test.ts

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import extractCommand from "../src/lingui-extract"
33
import extractExperimentalCommand from "../src/lingui-extract-experimental"
44
import { command as compileCommand } from "../src/lingui-compile"
55
import fs from "fs/promises"
6+
import { sync } from "glob"
67
import nodepath from "path"
78
import { makeConfig } from "@lingui/conf"
89
import { listingToHumanReadable, readFsToJson } from "../src/tests"
@@ -21,13 +22,18 @@ async function prepare(caseFolderName: string) {
2122

2223
const actualPath = nodepath.join(rootDir, "actual")
2324
const expectedPath = nodepath.join(rootDir, "expected")
25+
const existingPath = nodepath.join(rootDir, "existing")
2426

2527
await fs.rm(actualPath, {
2628
recursive: true,
2729
force: true,
2830
})
2931

30-
return { rootDir, actualPath, expectedPath }
32+
if (sync(existingPath).length === 1) {
33+
await fs.cp(existingPath, actualPath, { recursive: true })
34+
}
35+
36+
return { rootDir, actualPath, existingPath, expectedPath }
3137
}
3238

3339
describe("E2E Extractor Test", () => {
@@ -171,12 +177,6 @@ describe("E2E Extractor Test", () => {
171177
"extractor-experimental"
172178
)
173179

174-
await fs.cp(
175-
nodepath.join(rootDir, "existing"),
176-
nodepath.join(rootDir, "actual"),
177-
{ recursive: true }
178-
)
179-
180180
await mockConsole(async (console) => {
181181
const config = makeConfig({
182182
rootDir: rootDir,
@@ -231,12 +231,6 @@ describe("E2E Extractor Test", () => {
231231
"extractor-experimental-clean"
232232
)
233233

234-
await fs.cp(
235-
nodepath.join(rootDir, "existing"),
236-
nodepath.join(rootDir, "actual"),
237-
{ recursive: true }
238-
)
239-
240234
await mockConsole(async (console) => {
241235
const result = await extractExperimentalCommand(
242236
makeConfig({
@@ -285,4 +279,30 @@ describe("E2E Extractor Test", () => {
285279
compareFolders(actualPath, expectedPath)
286280
})
287281
})
282+
283+
it("should extract consistently with files argument", async () => {
284+
const { rootDir, actualPath, expectedPath } = await prepare(
285+
"extract-partial-consistency"
286+
)
287+
288+
await extractCommand(
289+
makeConfig({
290+
rootDir: rootDir,
291+
locales: ["en"],
292+
sourceLocale: "en",
293+
format: "po",
294+
catalogs: [
295+
{
296+
path: "<rootDir>/actual/{locale}",
297+
include: ["<rootDir>/fixtures"],
298+
},
299+
],
300+
}),
301+
{
302+
files: [nodepath.join(rootDir, "fixtures", "file-b.tsx")],
303+
}
304+
)
305+
306+
compareFolders(actualPath, expectedPath)
307+
})
288308
})

packages/conf/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)
7+
8+
**Note:** Version bump only for package @lingui/conf
9+
610
# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)
711

812
**Note:** Version bump only for package @lingui/conf

0 commit comments

Comments
 (0)