Skip to content

Commit

Permalink
fix(cli): sorting issue when different locales are used on host machi…
Browse files Browse the repository at this point in the history
…nes (#1808)
  • Loading branch information
Kepro authored Nov 29, 2023
1 parent d0fbc21 commit 4b8b2a7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/cli/src/api/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,15 @@ function orderByOrigin<T extends ExtractedCatalogType>(messages: T): T {
}

export function orderByMessage<T extends ExtractedCatalogType>(messages: T): T {
// hardcoded en-US locale to have consistent sorting
// @see https://github.com/lingui/js-lingui/pull/1808
const collator = new Intl.Collator("en-US")

return Object.keys(messages)
.sort((a, b) => {
const aMsg = messages[a].message || ""
const bMsg = messages[b].message || ""
return aMsg.localeCompare(bMsg)
return collator.compare(aMsg, bMsg)
})
.reduce((acc, key) => {
;(acc as any)[key] = messages[key]
Expand Down

1 comment on commit 4b8b2a7

@vercel
Copy link

@vercel vercel bot commented on 4b8b2a7 Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.