Skip to content

Commit

Permalink
feat: change default orderBy to message (#1519)
Browse files Browse the repository at this point in the history
  • Loading branch information
taozhou-glean authored Mar 14, 2023
1 parent 6a5a5f0 commit 419f9f9
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 56 deletions.
34 changes: 17 additions & 17 deletions packages/cli/test/extract-po-format/expected/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ msgstr ""
"X-Generator: @lingui/cli\n"
"Language: en\n"

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

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

#. js-lingui-id: 1nGWAC
#: fixtures/file-a.ts:4
msgid "Hello world"
Expand All @@ -18,29 +30,17 @@ msgctxt "custom context"
msgid "Hello world"
msgstr "Hello world"

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

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

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

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

#: fixtures/file-b.tsx:15
#, explicit-id
msgid "jsx.custom.id"
msgstr "This JSX element has custom id"

#: fixtures/file-a.ts:11
#, explicit-id
msgid "custom.id"
msgstr "This message has custom id"
32 changes: 16 additions & 16 deletions packages/cli/test/extract-po-format/expected/pl.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ msgstr ""
"X-Generator: @lingui/cli\n"
"Language: pl\n"

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

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

#. js-lingui-id: 1nGWAC
#: fixtures/file-a.ts:4
msgid "Hello world"
Expand All @@ -18,29 +30,17 @@ msgctxt "custom context"
msgid "Hello world"
msgstr ""

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

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

#: fixtures/file-a.ts:11
#: fixtures/file-b.tsx:15
#, explicit-id
msgid "custom.id"
msgstr ""

#. this is a comment
#. js-lingui-id: f9Atdk
#: fixtures/file-b.tsx:6
msgid "Hello this is JSX Translation"
msgid "jsx.custom.id"
msgstr ""

#: fixtures/file-b.tsx:15
#: fixtures/file-a.ts:11
#, explicit-id
msgid "jsx.custom.id"
msgid "custom.id"
msgstr ""
32 changes: 16 additions & 16 deletions packages/cli/test/extract-template-po-format/expected/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"

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

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

#. js-lingui-id: 1nGWAC
#: fixtures/file-a.ts:4
msgid "Hello world"
Expand All @@ -17,29 +29,17 @@ msgctxt "custom context"
msgid "Hello world"
msgstr ""

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

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

#: fixtures/file-a.ts:11
#: fixtures/file-b.tsx:15
#, explicit-id
msgid "custom.id"
msgstr ""

#. this is a comment
#. js-lingui-id: f9Atdk
#: fixtures/file-b.tsx:6
msgid "Hello this is JSX Translation"
msgid "jsx.custom.id"
msgstr ""

#: fixtures/file-b.tsx:15
#: fixtures/file-a.ts:11
#, explicit-id
msgid "jsx.custom.id"
msgid "custom.id"
msgstr ""
2 changes: 1 addition & 1 deletion packages/conf/src/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exports[`@lingui/conf should return default config 1`] = `
locales: [
en-gb,
],
orderBy: messageId,
orderBy: message,
pseudoLocale: ,
rootDir: .,
runtimeConfigModule: {
Expand Down
2 changes: 1 addition & 1 deletion packages/conf/src/makeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const defaultConfig: LinguiConfig = {
format: "po",
formatOptions: { origins: true, lineNumbers: true },
locales: [],
orderBy: "messageId",
orderBy: "message",
pseudoLocale: "",
rootDir: ".",
runtimeConfigModule: ["@lingui/core", "i18n"],
Expand Down
10 changes: 5 additions & 5 deletions website/docs/ref/conf.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,18 +363,18 @@ Locale tags which are used in the project. [`extract`](/docs/ref/cli.md#extract)

## orderBy

Default: `messageId`
Default: `message`

Order of messages in catalog:

#### messageId

Sort by the message ID, `js-lingui-id` will be used if no custom id provided.

#### message

Sort by source message.

#### messageId

Sort by the message ID, `js-lingui-id` will be used if no custom id provided.

#### origin

Sort by message origin (e.g. `App.js:3`)
Expand Down
2 changes: 2 additions & 0 deletions website/docs/releases/migration-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Also, we've added a possibility to provide a context for the message. For more d

The context feature affects the message ID generation and adds the `msgctxt` parameter in case of the PO catalog format extraction.

This also affects the `orderBy` with `messageId` as now the generated id is used when custom id is absent. To avoid confusion, we switched the default `orderBy` to use the source message (`message`) instead.

### Change in generated ICU messages for nested JSX Macros

We have made a small change in how Lingui generates ICU messages for nested JSX Macros. We have removed leading spaces from the texts in all cases.
Expand Down

0 comments on commit 419f9f9

Please sign in to comment.