Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bodnar committed Nov 7, 2024
2 parents 473b70f + 8dcb749 commit 6c4193a
Show file tree
Hide file tree
Showing 31 changed files with 714 additions and 24 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)

### Bug Fixes

- **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))

### Features

- **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))

# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)

### Features
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-plugin-extract-messages/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)

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

# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)

**Note:** Version bump only for package @lingui/babel-plugin-extract-messages
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)

### Bug Fixes

- **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))

# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)

**Note:** Version bump only for package @lingui/cli
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/api/catalog/mergeCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function mergeCatalog(
const obsoleteMessages = obsoleteKeys.map((key) => ({
[key]: {
...prevCatalog[key],
obsolete: !options.files,
...(!options.files && { obsolete: true }),
},
}))

Expand Down
53 changes: 53 additions & 0 deletions packages/cli/test/extract-partial-consistency/existing/en.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
msgid ""
msgstr ""
"POT-Creation-Date: 2023-03-15 10:00+0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"
"Language: en\n"
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Plural-Forms: \n"

#. js-lingui-explicit-id
#: fixtures/file-a.ts:11
#~ msgid "custom.id"
#~ msgstr "This message has custom id"

#. js-lingui-explicit-id
#: fixtures/file-a.ts:22
#: fixtures/file-a.ts:23
msgid "addToCart"
msgstr "Add To Cart with change ignored"

#. this is a comment
#: fixtures/file-b.tsx:6
msgid "Hello this is JSX Translation"
msgstr "Hello this is JSX Translation"

#: fixtures/file-b.tsx:11
msgctxt "my context"
msgid "Hello this is JSX Translation"
msgstr "Hello this is JSX Translation"

#: fixtures/file-a.ts:4
msgid "Hello world"
msgstr "Hello world"

#: fixtures/file-a.ts:6
msgctxt "custom context"
msgid "Hello world"
msgstr "Hello world"

#: fixtures/file-a.ts:16
msgid "Message in descriptor"
msgstr "Message in descriptor"

#. js-lingui-explicit-id
#: fixtures/file-b.tsx:15
msgid "jsx.custom.id"
msgstr "This JSX element has custom id"
53 changes: 53 additions & 0 deletions packages/cli/test/extract-partial-consistency/expected/en.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
msgid ""
msgstr ""
"POT-Creation-Date: 2023-03-15 10:00+0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"
"Language: en\n"
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Plural-Forms: \n"

#. js-lingui-explicit-id
#: fixtures/file-a.ts:11
#~ msgid "custom.id"
#~ msgstr "This message has custom id"

#. js-lingui-explicit-id
#: fixtures/file-a.ts:22
#: fixtures/file-a.ts:23
msgid "addToCart"
msgstr "Add To Cart with change ignored"

#. this is a comment
#: fixtures/file-b.tsx:6
msgid "Hello this is JSX Translation"
msgstr "Hello this is JSX Translation"

#: fixtures/file-b.tsx:11
msgctxt "my context"
msgid "Hello this is JSX Translation"
msgstr "Hello this is JSX Translation"

#: fixtures/file-a.ts:4
msgid "Hello world"
msgstr "Hello world"

#: fixtures/file-a.ts:6
msgctxt "custom context"
msgid "Hello world"
msgstr "Hello world"

#: fixtures/file-a.ts:16
msgid "Message in descriptor"
msgstr "Message in descriptor"

#. js-lingui-explicit-id
#: fixtures/file-b.tsx:15
msgid "jsx.custom.id"
msgstr "This JSX element has custom id"
23 changes: 23 additions & 0 deletions packages/cli/test/extract-partial-consistency/fixtures/file-a.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { i18n } from "@lingui/core"
import { defineMessage, t } from "@lingui/macro"

const msg = t`Hello world`

const msg2 = t({
message: "Hello world",
context: "custom context",
})

const msg3 = null /* original translation commented to mark message obsolete *//*t({
message: "This message has custom id",
id: "custom.id",
})*/

const msgDescriptor = defineMessage({
message: "Message in descriptor",
})

i18n._(msgDescriptor)

i18n._("addToCart")
i18n._({id: "addToCart", message: "Add To Cart with change ignored"})
16 changes: 16 additions & 0 deletions packages/cli/test/extract-partial-consistency/fixtures/file-b.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Trans } from "@lingui/macro"
import React from "react"

export function MyComponent() {
return (
<Trans comment={"this is a comment"}>Hello this is JSX Translation</Trans>
)
}

export function MyComponent2() {
return <Trans context="my context">Hello this is JSX Translation</Trans>
}

export function MyComponent3() {
return <Trans id={"jsx.custom.id"}>This JSX element has custom id</Trans>
}
46 changes: 33 additions & 13 deletions packages/cli/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import extractCommand from "../src/lingui-extract"
import extractExperimentalCommand from "../src/lingui-extract-experimental"
import { command as compileCommand } from "../src/lingui-compile"
import fs from "fs/promises"
import { sync } from "glob"
import nodepath from "path"
import { makeConfig } from "@lingui/conf"
import { listingToHumanReadable, readFsToJson } from "../src/tests"
Expand All @@ -21,13 +22,18 @@ async function prepare(caseFolderName: string) {

const actualPath = nodepath.join(rootDir, "actual")
const expectedPath = nodepath.join(rootDir, "expected")
const existingPath = nodepath.join(rootDir, "existing")

await fs.rm(actualPath, {
recursive: true,
force: true,
})

return { rootDir, actualPath, expectedPath }
if (sync(existingPath).length === 1) {
await fs.cp(existingPath, actualPath, { recursive: true })
}

return { rootDir, actualPath, existingPath, expectedPath }
}

describe("E2E Extractor Test", () => {
Expand Down Expand Up @@ -171,12 +177,6 @@ describe("E2E Extractor Test", () => {
"extractor-experimental"
)

await fs.cp(
nodepath.join(rootDir, "existing"),
nodepath.join(rootDir, "actual"),
{ recursive: true }
)

await mockConsole(async (console) => {
const config = makeConfig({
rootDir: rootDir,
Expand Down Expand Up @@ -231,12 +231,6 @@ describe("E2E Extractor Test", () => {
"extractor-experimental-clean"
)

await fs.cp(
nodepath.join(rootDir, "existing"),
nodepath.join(rootDir, "actual"),
{ recursive: true }
)

await mockConsole(async (console) => {
const result = await extractExperimentalCommand(
makeConfig({
Expand Down Expand Up @@ -285,4 +279,30 @@ describe("E2E Extractor Test", () => {
compareFolders(actualPath, expectedPath)
})
})

it("should extract consistently with files argument", async () => {
const { rootDir, actualPath, expectedPath } = await prepare(
"extract-partial-consistency"
)

await extractCommand(
makeConfig({
rootDir: rootDir,
locales: ["en"],
sourceLocale: "en",
format: "po",
catalogs: [
{
path: "<rootDir>/actual/{locale}",
include: ["<rootDir>/fixtures"],
},
],
}),
{
files: [nodepath.join(rootDir, "fixtures", "file-b.tsx")],
}
)

compareFolders(actualPath, expectedPath)
})
})
4 changes: 4 additions & 0 deletions packages/conf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)

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

# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)

**Note:** Version bump only for package @lingui/conf
Expand Down
4 changes: 4 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)

**Note:** Version bump only for package @lingui/core

# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)

**Note:** Version bump only for package @lingui/core
Expand Down
4 changes: 4 additions & 0 deletions packages/detect-locale/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)

**Note:** Version bump only for package @lingui/detect-locale

# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)

**Note:** Version bump only for package @lingui/detect-locale
Expand Down
2 changes: 1 addition & 1 deletion packages/detect-locale/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lingui/detect-locale",
"version": "4.13.0",
"version": "4.14.0",
"sideEffects": false,
"description": "@Lingui package to help you find the correct browser/server locale",
"main": "./dist/index.cjs",
Expand Down
4 changes: 4 additions & 0 deletions packages/extractor-vue/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)

**Note:** Version bump only for package @lingui/extractor-vue

# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)

**Note:** Version bump only for package @lingui/extractor-vue
Expand Down
4 changes: 4 additions & 0 deletions packages/format-csv/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)

**Note:** Version bump only for package @lingui/format-csv

# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)

**Note:** Version bump only for package @lingui/format-csv
Expand Down
4 changes: 4 additions & 0 deletions packages/format-json/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)

**Note:** Version bump only for package @lingui/format-json

# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)

**Note:** Version bump only for package @lingui/format-json
Expand Down
6 changes: 6 additions & 0 deletions packages/format-po-gettext/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [4.14.0](https://github.com/lingui/js-lingui/compare/v4.13.0...v4.14.0) (2024-11-07)

### Features

- **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))

# [4.13.0](https://github.com/lingui/js-lingui/compare/v4.12.0...v4.13.0) (2024-10-15)

### Features
Expand Down
1 change: 1 addition & 0 deletions packages/format-po-gettext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@lingui/format-po": "5.0.0-next.3",
"@lingui/message-utils": "5.0.0-next.3",
"@messageformat/parser": "^5.0.0",
"cldr-core": "^45.0.0",
"node-gettext": "^3.0.0",
"plurals-cldr": "^2.0.1",
"pofile": "^1.1.4"
Expand Down
Loading

0 comments on commit 6c4193a

Please sign in to comment.