Skip to content

Commit

Permalink
fix: po-gettext format issues with CLI (#1073)
Browse files Browse the repository at this point in the history
  • Loading branch information
nakkamarra committed Jun 4, 2021
1 parent 9990eba commit a529aca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/cli/src/api/formats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const formats: Record<CatalogFormat, CatalogFormatter> = {

type CatalogFormatOptionsInternal = {
locale: string
disableSelectWarning?: boolean
} & CatalogFormatOptions

export type CatalogFormatter = {
Expand Down
10 changes: 7 additions & 3 deletions packages/cli/src/api/formats/po-gettext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ const serialize = (items: CatalogType, options) =>
// The extractedComments array may be modified in this method, so create a new array with the message's elements.
// Destructuring `undefined` is forbidden, so fallback to `[]` if the message has no extracted comments.
item.extractedComments = [...(message.extractedComments ?? [])]

if (options.origins) {
item.references = message.origin ? message.origin.map(joinOrigin) : []

if (options.origins !== false) {
if (message.origin && options.lineNumbers === false) {
item.references = message.origin.map(msg => msg.slice(0, -1)).map(joinOrigin)
} else {
item.references = message.origin ? message.origin.map(joinOrigin) : []
}
}

// @ts-ignore: Figure out how to set this flag
Expand Down

1 comment on commit a529aca

@vercel
Copy link

@vercel vercel bot commented on a529aca Jun 4, 2021

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.